]> git.sur5r.net Git - openldap/commitdiff
ITS#4088 proposed fix
authorHoward Chu <hyc@openldap.org>
Sun, 16 Oct 2005 07:37:36 +0000 (07:37 +0000)
committerHoward Chu <hyc@openldap.org>
Sun, 16 Oct 2005 07:37:36 +0000 (07:37 +0000)
servers/slapd/back-bdb/cache.c
servers/slapd/back-bdb/id2entry.c
servers/slapd/back-bdb/proto-bdb.h
servers/slapd/back-bdb/tools.c

index d155ef7c2ea9cdca7c1eaeb7d8550ef11002cfcd..598549e8cd48c1108eb38ca8eea791f00667e30b 100644 (file)
@@ -384,7 +384,7 @@ bdb_cache_find_ndn(
 /* Walk up the tree from a child node, looking for an ID that's already
  * been linked into the cache.
  */
-static int
+int
 hdb_cache_find_parent(
        Operation *op,
        DB_TXN *txn,
index 9a1e7d520c3ad626cdccc0222685cb5cbbc5a82d..bb1a955f8959593d9c365bd23bc0c1e0d127e5ee 100644 (file)
@@ -212,14 +212,10 @@ int bdb_entry_return(
                e->e_nname.bv_val = NULL;
        }
 #ifndef SLAP_ZONE_ALLOC
-#ifndef BDB_HIER
        /* In tool mode the e_bv buffer is realloc'd, leave it alone */
        if( !(slapMode & SLAP_TOOL_MODE) ) {
                free( e->e_bv.bv_val );
        }
-#else
-       free( e->e_bv.bv_val );
-#endif /* BDB_HIER */
 #endif /* !SLAP_ZONE_ALLOC */
 
 #ifdef SLAP_ZONE_ALLOC
index a9a3b831560eac0568e5e8d3f563730389fbb27e..232289f7c924c26153a546b3e1f31da081757477 100644 (file)
@@ -443,6 +443,7 @@ void bdb_unlocked_cache_return_entry_rw( Cache *cache, Entry *e, int rw );
 #define bdb_cache_find_id                      BDB_SYMBOL(cache_find_id)
 #define bdb_cache_find_info                    BDB_SYMBOL(cache_find_info)
 #define bdb_cache_find_ndn                     BDB_SYMBOL(cache_find_ndn)
+#define bdb_cache_find_parent          BDB_SYMBOL(cache_find_parent)
 #define bdb_cache_modify                       BDB_SYMBOL(cache_modify)
 #define bdb_cache_modrdn                       BDB_SYMBOL(cache_modrdn)
 #define bdb_cache_release_all          BDB_SYMBOL(cache_release_all)
@@ -495,6 +496,13 @@ int bdb_cache_find_id(
        u_int32_t       locker,
        DB_LOCK         *lock
 );
+int
+bdb_cache_find_parent(
+       Operation *op,
+       DB_TXN *txn,
+       ID id,
+       EntryInfo **res
+);
 int bdb_cache_delete(
        Cache   *cache,
        Entry   *e,
index bafba3549e7a2ef597aba98f95496bcdc354d59f..6064d938421ab1eb04b8c5dfa0eb1bbc6a115de3 100644 (file)
@@ -185,15 +185,12 @@ Entry* bdb_tool_entry_get( BackendDB *be, ID id )
 {
        int rc;
        Entry *e = NULL;
-#ifndef BDB_HIER
        struct berval bv;
-#endif
 
        assert( be != NULL );
        assert( slapMode & SLAP_TOOL_MODE );
        assert( data.data != NULL );
 
-#ifndef BDB_HIER
        DBT2bv( &data, &bv );
 
 #ifdef SLAP_ZONE_ALLOC
@@ -206,7 +203,7 @@ Entry* bdb_tool_entry_get( BackendDB *be, ID id )
        if( rc == LDAP_SUCCESS ) {
                e->e_id = id;
        }
-#else
+#ifdef BDB_HIER
        {
                EntryInfo *ei = NULL;
                Operation op = {0};
@@ -217,9 +214,15 @@ Entry* bdb_tool_entry_get( BackendDB *be, ID id )
                op.o_tmpmemctx = NULL;
                op.o_tmpmfuncs = &ch_mfuncs;
 
-               rc = bdb_cache_find_id( &op, NULL, id, &ei, 0, 0, NULL );
-               if ( rc == LDAP_SUCCESS )
-                       e = ei->bei_e;
+               rc = bdb_cache_find_parent( &op, NULL, id, &ei );
+               if ( rc == LDAP_SUCCESS ) {
+                       bdb_cache_entryinfo_unlock( ei );
+                       e->e_private = ei;
+                       ei->bei_e = e;
+                       bdb_fix_dn( e, 0 );
+                       ei->bei_e = NULL;
+                       e->e_private = NULL;
+               }
        }
 #endif
        return e;