]> git.sur5r.net Git - openldap/commitdiff
ITS#8725 backover fixes for async
authorHoward Chu <hyc@openldap.org>
Tue, 17 Jan 2017 09:44:03 +0000 (09:44 +0000)
committerHoward Chu <hyc@openldap.org>
Fri, 8 Sep 2017 16:25:55 +0000 (17:25 +0100)
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

servers/slapd/backover.c

index a673fb36c62575948712cd53fd7e45c79cbd809a..97a42770d365ae45aaa980b5fe5985658fa9607c 100644 (file)
@@ -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;
+                       }
                }
        }