From: Howard Chu Date: Sun, 16 Oct 2005 07:37:36 +0000 (+0000) Subject: ITS#4088 proposed fix X-Git-Tag: OPENLDAP_REL_ENG_2_2_MP~228 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=c44210a8bf19f78e1dc8abf92470c19da21c02a5;p=openldap ITS#4088 proposed fix --- diff --git a/servers/slapd/back-bdb/cache.c b/servers/slapd/back-bdb/cache.c index d155ef7c2e..598549e8cd 100644 --- a/servers/slapd/back-bdb/cache.c +++ b/servers/slapd/back-bdb/cache.c @@ -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, diff --git a/servers/slapd/back-bdb/id2entry.c b/servers/slapd/back-bdb/id2entry.c index 9a1e7d520c..bb1a955f89 100644 --- a/servers/slapd/back-bdb/id2entry.c +++ b/servers/slapd/back-bdb/id2entry.c @@ -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 diff --git a/servers/slapd/back-bdb/proto-bdb.h b/servers/slapd/back-bdb/proto-bdb.h index a9a3b83156..232289f7c9 100644 --- a/servers/slapd/back-bdb/proto-bdb.h +++ b/servers/slapd/back-bdb/proto-bdb.h @@ -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, diff --git a/servers/slapd/back-bdb/tools.c b/servers/slapd/back-bdb/tools.c index bafba3549e..6064d93842 100644 --- a/servers/slapd/back-bdb/tools.c +++ b/servers/slapd/back-bdb/tools.c @@ -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;