]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-bdb/search.c
Fix prev commit, cleanup fakeroot entry before freeing
[openldap] / servers / slapd / back-bdb / search.c
index f9a561a9982969e691b6bd70ff370e18ece9170a..94dd7c87ae4eb34b86dc54402d68b708a08d4b4e 100644 (file)
@@ -184,7 +184,7 @@ static int search_aliases(
 
        /* Find all aliases in database */
        BDB_IDL_ZERO( aliases );
-       rs->sr_err = bdb_filter_candidates( op, &af, aliases,
+       rs->sr_err = bdb_filter_candidates( op, locker, &af, aliases,
                curscop, visited );
        if (rs->sr_err != LDAP_SUCCESS) {
                return rs->sr_err;
@@ -206,7 +206,7 @@ static int search_aliases(
                 * to the cumulative list of candidates.
                 */
                BDB_IDL_CPY( curscop, aliases );
-               rs->sr_err = bdb_dn2idl( op, e, subscop,
+               rs->sr_err = bdb_dn2idl( op, locker, &e->e_nname, BEI(e), subscop,
                        subscop2+BDB_IDL_DB_SIZE );
                if (first) {
                        first = 0;
@@ -311,9 +311,9 @@ bdb_search( Operation *op, SlapReply *rs )
        ID              id, cursor;
        ID              candidates[BDB_IDL_UM_SIZE];
        ID              scopes[BDB_IDL_DB_SIZE];
-       Entry           *e = NULL, base, e_root = {0};
+       Entry           *e = NULL, base, *e_root;
        Entry           *matched = NULL;
-       EntryInfo       *ei, ei_root = {0};
+       EntryInfo       *ei;
        struct berval   realbase = BER_BVNULL;
        slap_mask_t     mask;
        int             manageDSAit;
@@ -348,15 +348,10 @@ bdb_search( Operation *op, SlapReply *rs )
                }
        }
 
+       e_root = bdb->bi_cache.c_dntree.bei_e;
        if ( op->o_req_ndn.bv_len == 0 ) {
                /* DIT root special case */
-               ei_root.bei_e = &e_root;
-               ei_root.bei_parent = &ei_root;
-               e_root.e_private = &ei_root;
-               e_root.e_id = 0;
-               BER_BVSTR( &e_root.e_nname, "" );
-               BER_BVSTR( &e_root.e_name, "" );
-               ei = &ei_root;
+               ei = e_root->e_private;
                rs->sr_err = LDAP_SUCCESS;
        } else {
                if ( op->ors_deref & LDAP_DEREF_FINDING ) {
@@ -486,14 +481,14 @@ dn2entry_retry:
 #ifdef SLAP_ZONE_ALLOC
                slap_zn_runlock(bdb->bi_cache.c_zctx, e);
 #endif
-               if ( e != &e_root ) {
+               if ( e != e_root ) {
                        bdb_cache_return_entry_r(bdb, e, &lock);
                }
                send_ldap_result( op, rs );
                return rs->sr_err;
        }
 
-       if ( !manageDSAit && e != &e_root && is_entry_referral( e ) ) {
+       if ( !manageDSAit && e != e_root && is_entry_referral( e ) ) {
                /* entry is a referral, don't allow add */
                struct berval matched_dn = BER_BVNULL;
                BerVarray erefs = NULL;
@@ -543,7 +538,7 @@ dn2entry_retry:
 #ifdef SLAP_ZONE_ALLOC
                slap_zn_runlock(bdb->bi_cache.c_zctx, e);
 #endif
-               if ( e != &e_root ) {
+               if ( e != e_root ) {
                        bdb_cache_return_entry_r(bdb, e, &lock);
                }
                send_ldap_result( op, rs );
@@ -566,7 +561,7 @@ dn2entry_retry:
 #ifdef SLAP_ZONE_ALLOC
        slap_zn_runlock(bdb->bi_cache.c_zctx, e);
 #endif
-       if ( e != &e_root ) {
+       if ( e != e_root ) {
                bdb_cache_return_entry_r(bdb, e, &lock);
        }
        e = NULL;
@@ -1100,11 +1095,11 @@ static int search_candidates(
        if( op->ors_deref & LDAP_DEREF_SEARCHING ) {
                rc = search_aliases( op, rs, e, locker, ids, scopes, stack );
        } else {
-               rc = bdb_dn2idl( op, e, ids, stack );
+               rc = bdb_dn2idl( op, locker, &e->e_nname, BEI(e), ids, stack );
        }
 
        if ( rc == LDAP_SUCCESS ) {
-               rc = bdb_filter_candidates( op, &f, ids,
+               rc = bdb_filter_candidates( op, locker, &f, ids,
                        stack, stack+BDB_IDL_UM_SIZE );
        }