mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-12-24 00:29:35 -05:00
ITS#8725 Add SLAPD_ASYNCOP return code
Tell frontend the op will finish asynchronously, leave it alone
This commit is contained in:
parent
738723866e
commit
75999a18c3
10 changed files with 74 additions and 1 deletions
|
|
@ -194,6 +194,11 @@ do_add( Operation *op, SlapReply *rs )
|
|||
rc = frontendDB->be_add( op, rs );
|
||||
LDAP_SLIST_REMOVE(&op->o_extra, &oex.oe, OpExtra, oe_next);
|
||||
|
||||
if ( rc == SLAPD_ASYNCOP ) {
|
||||
/* skip cleanup */
|
||||
return rc;
|
||||
}
|
||||
|
||||
#ifdef LDAP_X_TXN
|
||||
if ( rc == LDAP_X_TXN_SPECIFY_OKAY ) {
|
||||
/* skip cleanup */
|
||||
|
|
|
|||
|
|
@ -717,6 +717,16 @@ cleanup:
|
|||
return rc;
|
||||
}
|
||||
|
||||
static int
|
||||
over_op_func_cleanup( Operation *op, SlapReply *rs )
|
||||
{
|
||||
slap_callback *cb = op->o_callback;
|
||||
if ( rs->sr_type == REP_RESULT && cb != NULL) {
|
||||
op->o_callback = cb->sc_next;
|
||||
ch_free( cb );
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
over_op_func(
|
||||
Operation *op,
|
||||
|
|
@ -743,7 +753,7 @@ over_op_func(
|
|||
db.be_flags |= SLAP_DBFLAG_OVERLAY;
|
||||
op->o_bd = &db;
|
||||
}
|
||||
cb->sc_cleanup = NULL;
|
||||
cb->sc_cleanup = over_op_func_cleanup;
|
||||
cb->sc_response = over_back_response;
|
||||
cb->sc_writewait = NULL;
|
||||
cb->sc_next = op->o_callback;
|
||||
|
|
|
|||
|
|
@ -125,6 +125,10 @@ do_compare(
|
|||
|
||||
op->o_bd = frontendDB;
|
||||
rs->sr_err = frontendDB->be_compare( op, rs );
|
||||
if ( rs->sr_err == SLAPD_ASYNCOP ) {
|
||||
/* skip cleanup */
|
||||
return rs->sr_err;
|
||||
}
|
||||
|
||||
cleanup:;
|
||||
op->o_tmpfree( op->o_req_dn.bv_val, op->o_tmpmemctx );
|
||||
|
|
|
|||
|
|
@ -1040,6 +1040,26 @@ conn_counter_init( Operation *op, void *ctx )
|
|||
op->o_counters = vsc;
|
||||
}
|
||||
|
||||
void
|
||||
connection_op_finish( Operation *op )
|
||||
{
|
||||
Connection *conn = op->o_conn;
|
||||
void *memctx_null = NULL;
|
||||
|
||||
ldap_pvt_thread_mutex_lock( &conn->c_mutex );
|
||||
|
||||
if ( op->o_tag == LDAP_REQ_BIND && conn->c_conn_state == SLAP_C_BINDING )
|
||||
conn->c_conn_state = SLAP_C_ACTIVE;
|
||||
|
||||
ber_set_option( op->o_ber, LBER_OPT_BER_MEMCTX, &memctx_null );
|
||||
|
||||
LDAP_STAILQ_REMOVE( &conn->c_ops, op, Operation, o_next);
|
||||
LDAP_STAILQ_NEXT(op, o_next) = NULL;
|
||||
conn->c_n_ops_executing--;
|
||||
conn->c_n_ops_completed++;
|
||||
ldap_pvt_thread_mutex_unlock( &conn->c_mutex );
|
||||
}
|
||||
|
||||
static void *
|
||||
connection_operation( void *ctx, void *arg_v )
|
||||
{
|
||||
|
|
@ -1147,6 +1167,17 @@ operations_error:
|
|||
if ( rc == SLAPD_DISCONNECT ) {
|
||||
tag = LBER_ERROR;
|
||||
|
||||
} else if ( rc == SLAPD_ASYNCOP ) {
|
||||
/* someone has claimed ownership of the op
|
||||
* to complete it later. Don't do anything
|
||||
* else with it now. Detach memctx too.
|
||||
*/
|
||||
slap_sl_mem_setctx( ctx, NULL );
|
||||
ldap_pvt_thread_mutex_lock( &conn->c_mutex );
|
||||
connection_resched( conn );
|
||||
ldap_pvt_thread_mutex_unlock( &conn->c_mutex );
|
||||
return NULL;
|
||||
|
||||
} else if ( opidx != SLAP_OP_LAST ) {
|
||||
/* increment completed operations count
|
||||
* only if operation was initiated
|
||||
|
|
|
|||
|
|
@ -93,6 +93,10 @@ do_delete(
|
|||
|
||||
op->o_bd = frontendDB;
|
||||
rs->sr_err = frontendDB->be_delete( op, rs );
|
||||
if ( rs->sr_err == SLAPD_ASYNCOP ) {
|
||||
/* skip cleanup */
|
||||
return rs->sr_err;
|
||||
}
|
||||
|
||||
#ifdef LDAP_X_TXN
|
||||
if( rs->sr_err == LDAP_X_TXN_SPECIFY_OKAY ) {
|
||||
|
|
|
|||
|
|
@ -175,6 +175,10 @@ do_modify(
|
|||
|
||||
op->o_bd = frontendDB;
|
||||
rs->sr_err = frontendDB->be_modify( op, rs );
|
||||
if ( rs->sr_err == SLAPD_ASYNCOP ) {
|
||||
/* skip cleanup */
|
||||
return rs->sr_err;
|
||||
}
|
||||
|
||||
#ifdef LDAP_X_TXN
|
||||
if( rs->sr_err == LDAP_X_TXN_SPECIFY_OKAY ) {
|
||||
|
|
|
|||
|
|
@ -185,9 +185,14 @@ do_modrdn(
|
|||
op->o_bd = frontendDB;
|
||||
rs->sr_err = frontendDB->be_modrdn( op, rs );
|
||||
|
||||
if ( rs->sr_err == SLAPD_ASYNCOP ) {
|
||||
/* skip cleanup */
|
||||
return rs->sr_err;
|
||||
}
|
||||
#ifdef LDAP_X_TXN
|
||||
if( rs->sr_err == LDAP_X_TXN_SPECIFY_OKAY ) {
|
||||
/* skip cleanup */
|
||||
return rs->sr_err;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -806,6 +806,9 @@ LDAP_SLAPD_F (const char *) connection_state2str LDAP_P(( int state ))
|
|||
LDAP_SLAPD_F (int) connection_read_activate LDAP_P((ber_socket_t s));
|
||||
LDAP_SLAPD_F (int) connection_write LDAP_P((ber_socket_t s));
|
||||
|
||||
LDAP_SLAPD_F (void) connection_op_finish LDAP_P((
|
||||
Operation *op ));
|
||||
|
||||
LDAP_SLAPD_F (unsigned long) connections_nextid(void);
|
||||
|
||||
LDAP_SLAPD_F (Connection *) connection_first LDAP_P(( ber_socket_t * ));
|
||||
|
|
|
|||
|
|
@ -245,6 +245,10 @@ do_search(
|
|||
|
||||
op->o_bd = frontendDB;
|
||||
rs->sr_err = frontendDB->be_search( op, rs );
|
||||
if ( rs->sr_err == SLAPD_ASYNCOP ) {
|
||||
/* skip cleanup */
|
||||
return rs->sr_err;
|
||||
}
|
||||
|
||||
return_results:;
|
||||
if ( !BER_BVISNULL( &op->o_req_dn ) ) {
|
||||
|
|
|
|||
|
|
@ -155,6 +155,9 @@ LDAP_BEGIN_DECL
|
|||
/* unknown config file directive */
|
||||
#define SLAP_CONF_UNKNOWN (-1026)
|
||||
|
||||
/* pseudo error code indicating async operation */
|
||||
#define SLAPD_ASYNCOP (-1027)
|
||||
|
||||
/* We assume "C" locale, that is US-ASCII */
|
||||
#define ASCII_SPACE(c) ( (c) == ' ' )
|
||||
#define ASCII_LOWER(c) ( (c) >= 'a' && (c) <= 'z' )
|
||||
|
|
|
|||
Loading…
Reference in a new issue