]> git.sur5r.net Git - openldap/commitdiff
ITS#5221
authorQuanah Gibson-Mount <quanah@openldap.org>
Tue, 27 Nov 2007 20:09:47 +0000 (20:09 +0000)
committerQuanah Gibson-Mount <quanah@openldap.org>
Tue, 27 Nov 2007 20:09:47 +0000 (20:09 +0000)
Fix dn2id cache for back-hdb rename ops

CHANGES
servers/slapd/back-bdb/cache.c

diff --git a/CHANGES b/CHANGES
index 21aabbdf5c4785c79162a804690f4d522cf6c509..54b31a0024e92329998352597645b662fd4e2801 100644 (file)
--- 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)
index 084a4080af6713d187768a259a3eba177b9f96aa..7cd7194ab7c407b04b7a27c5d338eb72e729de51 100644 (file)
@@ -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;