From: Howard Chu Date: Tue, 17 Jan 2017 09:44:03 +0000 (+0000) Subject: ITS#8725 backover fixes for async X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=63308ef6bb76d22588df61dd2a2211f8b1fcd57d;p=openldap ITS#8725 backover fixes for async Fix some valgrind race conditions - wait for frontend to finish up Don't set callbacks for abandon or unbind - since they have no response Use tmpalloc for backover callback --- diff --git a/servers/slapd/backover.c b/servers/slapd/backover.c index a673fb36c6..97a42770d3 100644 --- a/servers/slapd/backover.c +++ b/servers/slapd/backover.c @@ -327,7 +327,9 @@ over_access_allowed( } op->o_bd = be; - op->o_bd->bd_info = bi; + if ( SLAP_ISOVERLAY( op->o_bd ) ) { + op->o_bd->bd_info = bi; + } return rc; } @@ -383,7 +385,9 @@ overlay_entry_get_ov( } op->o_bd = be; - op->o_bd->bd_info = bi; + if ( SLAP_ISOVERLAY( op->o_bd ) ) { + op->o_bd->bd_info = bi; + } return rc; } @@ -455,7 +459,9 @@ overlay_entry_release_ov( } op->o_bd = be; - op->o_bd->bd_info = bi; + if ( SLAP_ISOVERLAY( op->o_bd ) ) { + op->o_bd->bd_info = bi; + } return rc; } @@ -543,7 +549,9 @@ over_acl_group( } op->o_bd = be; - op->o_bd->bd_info = bi; + if ( SLAP_ISOVERLAY( op->o_bd ) ) { + op->o_bd->bd_info = bi; + } return rc; } @@ -614,7 +622,9 @@ over_acl_attribute( } op->o_bd = be; - op->o_bd->bd_info = bi; + if ( SLAP_ISOVERLAY( op->o_bd ) ) { + op->o_bd->bd_info = bi; + } return rc; } @@ -723,7 +733,7 @@ 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 ); + op->o_tmpfree( cb, op->o_tmpmemctx ); } } @@ -738,7 +748,7 @@ over_op_func( slap_overinst *on; BackendDB *be = op->o_bd, db; slap_callback **sc; - slap_callback *cb = (slap_callback *) ch_malloc( sizeof( slap_callback )); + slap_callback *cb; int rc = SLAP_CB_CONTINUE; /* FIXME: used to happen for instance during abandon @@ -753,19 +763,24 @@ over_op_func( db.be_flags |= SLAP_DBFLAG_OVERLAY; op->o_bd = &db; } - cb->sc_cleanup = over_op_func_cleanup; - cb->sc_response = over_back_response; - cb->sc_writewait = NULL; - cb->sc_next = op->o_callback; - cb->sc_private = oi; - op->o_callback = cb; + if ( op->o_tag != LDAP_REQ_ABANDON && op->o_tag != LDAP_REQ_UNBIND ) { + cb = (slap_callback *)op->o_tmpcalloc( 1, sizeof(slap_callback), op->o_tmpmemctx ); + cb->sc_cleanup = over_op_func_cleanup; + cb->sc_response = over_back_response; + cb->sc_writewait = NULL; + cb->sc_next = op->o_callback; + cb->sc_private = oi; + op->o_callback = cb; + } rc = overlay_op_walk( op, rs, which, oi, on ); - for ( sc = &op->o_callback; *sc; sc = &(*sc)->sc_next ) { - if ( *sc == cb ) { - *sc = cb->sc_next; - ch_free( cb ); - break; + if ( rc != SLAPD_ASYNCOP && op->o_tag != LDAP_REQ_ABANDON && op->o_tag != LDAP_REQ_UNBIND ) { + for ( sc = &op->o_callback; *sc; sc = &(*sc)->sc_next ) { + if ( *sc == cb ) { + *sc = cb->sc_next; + op->o_tmpfree( cb, op->o_tmpmemctx ); + break; + } } }