]> git.sur5r.net Git - openldap/commitdiff
ITS#6758 back-bdb: Delay setting sr->sr_entry until we know it will be used
authorHallvard Furuseth <hallvard@openldap.org>
Fri, 31 Dec 2010 00:04:38 +0000 (00:04 +0000)
committerHallvard Furuseth <hallvard@openldap.org>
Fri, 31 Dec 2010 00:04:38 +0000 (00:04 +0000)
servers/slapd/back-bdb/search.c

index 9cc950f401c047cedf6ae2a0df76fd50712165f5..9de67b9c89da23108072d80463b5c174f6317524 100644 (file)
@@ -748,8 +748,6 @@ fetch_entry_retry:
                        goto loop_continue;
                }
 
-               rs->sr_entry = e;
-
                if ( is_entry_subentry( e ) ) {
                        if( op->oq_search.rs_scope != LDAP_SCOPE_BASE ) {
                                if(!get_subentries_visibility( op )) {
@@ -881,6 +879,7 @@ fetch_entry_retry:
                        blis.bli_lock = lock;
                        blis.bli_flag = BLI_DONTFREE;
 
+                       rs->sr_entry = e;
                        rs->sr_flags = REP_ENTRY_MUSTRELEASE;
 
                        send_search_reference( op, rs );
@@ -912,7 +911,7 @@ fetch_entry_retry:
                }
 
                /* if it matches the filter and scope, send it */
-               rs->sr_err = test_filter( op, rs->sr_entry, op->oq_search.rs_filter );
+               rs->sr_err = test_filter( op, e, op->oq_search.rs_filter );
 
                if ( rs->sr_err == LDAP_COMPARE_TRUE ) {
                        /* check size limit */
@@ -956,10 +955,13 @@ fetch_entry_retry:
                                rs->sr_attrs = op->oq_search.rs_attrs;
                                rs->sr_operational_attrs = NULL;
                                rs->sr_ctrls = NULL;
+                               rs->sr_entry = e;
+                               RS_ASSERT( e->e_private != NULL );
                                rs->sr_flags = REP_ENTRY_MUSTRELEASE;
                                rs->sr_err = LDAP_SUCCESS;
                                rs->sr_err = send_search_entry( op, rs );
                                rs->sr_attrs = NULL;
+                               rs->sr_entry = NULL;
 
                                /* send_search_entry will usually free it.
                                 * an overlay might leave its own copy here;
@@ -977,7 +979,6 @@ fetch_entry_retry:
                                                        OpExtra, oe_next );
                                        }
                                }
-                               rs->sr_entry = NULL;
                                e = NULL;
 
                                switch ( rs->sr_err ) {
@@ -1013,6 +1014,7 @@ loop_continue:
                        slap_zn_runlock(bdb->bi_cache.c_zctx, e);
 #endif
                        bdb_cache_return_entry_r( bdb, e , &lock );
+                       RS_ASSERT( rs->sr_entry == NULL );
                        e = NULL;
                        rs->sr_entry = NULL;
                }
@@ -1327,4 +1329,3 @@ send_paged_response(
 done:
        (void) ber_free_buf( ber );
 }
-