]> git.sur5r.net Git - openldap/commitdiff
More for #5221, don't muck with kids counters on simple renames
authorHoward Chu <hyc@openldap.org>
Wed, 21 Nov 2007 15:11:26 +0000 (15:11 +0000)
committerHoward Chu <hyc@openldap.org>
Wed, 21 Nov 2007 15:11:26 +0000 (15:11 +0000)
servers/slapd/back-bdb/cache.c

index 636ea7cf667a85ce958c96f510d008898e0bbed7..4e64631f998d4fb741a5e1d17171799181e89b90 100644 (file)
@@ -1158,11 +1158,15 @@ 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 ( pei->bei_kids < 2 )
-                       pei->bei_state |= CACHE_ENTRY_NO_KIDS | CACHE_ENTRY_NO_GRANDKIDS;
+
+       /* If new parent, decrement kid counts */
+       if ( ein ) {
+               pei->bei_ckids--;
+               if ( pei->bei_dkids ) {
+                       pei->bei_dkids--;
+                       if ( pei->bei_kids < 2 )
+                               pei->bei_state |= CACHE_ENTRY_NO_KIDS | CACHE_ENTRY_NO_GRANDKIDS;
+               }
        }
 #endif
 
@@ -1172,29 +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;
-       /* grandparent has grandkids */
-       if ( ein->bei_parent )
-               ein->bei_parent->bei_state &= ~CACHE_ENTRY_NO_GRANDKIDS;
 
+               /* 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;
 
+               ein->bei_ckids++;
+               if ( ein->bei_dkids ) ein->bei_dkids++;
+#endif
+       }
+
+#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 );
-
-       ein->bei_ckids++;
-       if ( ein->bei_dkids ) ein->bei_dkids++;
 #endif
+
        avl_insert( &ein->bei_kids, ei, bdb_rdn_cmp, avl_dup_error );
        bdb_cache_entryinfo_unlock( ein );
        return rc;