From: Quanah Gibson-Mount Date: Tue, 27 Nov 2007 20:09:47 +0000 (+0000) Subject: ITS#5221 X-Git-Tag: OPENLDAP_REL_ENG_2_4_7~46 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=51330ebdd7e5069307c73a681c8835a9c5a779ac;p=openldap ITS#5221 Fix dn2id cache for back-hdb rename ops --- diff --git a/CHANGES b/CHANGES index 21aabbdf5c..54b31a0024 100644 --- a/CHANGES +++ b/CHANGES @@ -13,6 +13,7 @@ OpenLDAP 2.4.7 Engineering Fixed slapd 3-way Multi-Master Replication (ITS#5238) Fixed slapd hash collisions in index slots (ITS#5183) Fixed slapd-bdb to report and fail on internal errors (ITS#5232) + Fixed slapd-hdb caching on rename ops (ITS#5221) Fixed slapo-pcache op->o_abandon handling (ITS#5187) Fixed slapo-ppolicy single password check on modify (ITS#5146) Fixed slapo-ppolicy internal search (ITS#5235) diff --git a/servers/slapd/back-bdb/cache.c b/servers/slapd/back-bdb/cache.c index 084a4080af..7cd7194ab7 100644 --- a/servers/slapd/back-bdb/cache.c +++ b/servers/slapd/back-bdb/cache.c @@ -1148,9 +1148,6 @@ bdb_cache_modrdn( free( ei->bei_nrdn.bv_val ); ber_dupbv( &ei->bei_nrdn, nrdn ); - if ( !pei->bei_kids ) - pei->bei_state |= CACHE_ENTRY_NO_KIDS | CACHE_ENTRY_NO_GRANDKIDS; - #ifdef BDB_HIER free( ei->bei_rdn.bv_val ); @@ -1161,8 +1158,16 @@ bdb_cache_modrdn( rdn.bv_len = ptr - rdn.bv_val; } ber_dupbv( &ei->bei_rdn, &rdn ); - pei->bei_ckids--; - if ( pei->bei_dkids ) pei->bei_dkids--; + + /* If new parent, decrement kid counts */ + if ( ein ) { + pei->bei_ckids--; + if ( pei->bei_dkids ) { + pei->bei_dkids--; + if ( pei->bei_dkids < 2 ) + pei->bei_state |= CACHE_ENTRY_NO_KIDS | CACHE_ENTRY_NO_GRANDKIDS; + } + } #endif if (!ein) { @@ -1171,27 +1176,32 @@ bdb_cache_modrdn( ei->bei_parent = ein; bdb_cache_entryinfo_unlock( pei ); bdb_cache_entryinfo_lock( ein ); - } - /* parent now has kids */ - if ( ein->bei_state & CACHE_ENTRY_NO_KIDS ) - ein->bei_state ^= CACHE_ENTRY_NO_KIDS; + /* new parent now has kids */ + if ( ein->bei_state & CACHE_ENTRY_NO_KIDS ) + ein->bei_state ^= CACHE_ENTRY_NO_KIDS; + /* grandparent has grandkids */ + if ( ein->bei_parent ) + ein->bei_parent->bei_state &= ~CACHE_ENTRY_NO_GRANDKIDS; #ifdef BDB_HIER - /* parent might now have grandkids */ - if ( ein->bei_state & CACHE_ENTRY_NO_GRANDKIDS && - !(ei->bei_state & (CACHE_ENTRY_NO_KIDS))) - ein->bei_state ^= CACHE_ENTRY_NO_GRANDKIDS; + /* parent might now have grandkids */ + if ( ein->bei_state & CACHE_ENTRY_NO_GRANDKIDS && + !(ei->bei_state & CACHE_ENTRY_NO_KIDS)) + ein->bei_state ^= CACHE_ENTRY_NO_GRANDKIDS; - { - /* Record the generation number of this change */ - ldap_pvt_thread_mutex_lock( &bdb->bi_modrdns_mutex ); - bdb->bi_modrdns++; - ei->bei_modrdns = bdb->bi_modrdns; - ldap_pvt_thread_mutex_unlock( &bdb->bi_modrdns_mutex ); + ein->bei_ckids++; + if ( ein->bei_dkids ) ein->bei_dkids++; +#endif } - ein->bei_ckids++; - if ( ein->bei_dkids ) ein->bei_dkids++; + +#ifdef BDB_HIER + /* Record the generation number of this change */ + ldap_pvt_thread_mutex_lock( &bdb->bi_modrdns_mutex ); + bdb->bi_modrdns++; + ei->bei_modrdns = bdb->bi_modrdns; + ldap_pvt_thread_mutex_unlock( &bdb->bi_modrdns_mutex ); #endif + avl_insert( &ein->bei_kids, ei, bdb_rdn_cmp, avl_dup_error ); bdb_cache_entryinfo_unlock( ein ); return rc;