]> git.sur5r.net Git - openldap/commitdiff
ITS#3857 fix bottom-up modrdn cascades, use a global modrdn counter.
authorHoward Chu <hyc@openldap.org>
Tue, 12 Jul 2005 13:17:56 +0000 (13:17 +0000)
committerHoward Chu <hyc@openldap.org>
Tue, 12 Jul 2005 13:17:56 +0000 (13:17 +0000)
servers/slapd/back-bdb/back-bdb.h
servers/slapd/back-bdb/cache.c
servers/slapd/back-bdb/init.c
servers/slapd/back-bdb/modrdn.c
servers/slapd/back-bdb/proto-bdb.h

index dea33f671d294c8a4f917c6afd1d2deae0fc374c..d6e9ecc20d5d0b147cddf2cfb7291772de63b5e9 100644 (file)
@@ -195,6 +195,10 @@ struct bdb_info {
 #define        BDB_UPD_CONFIG  0x04
 #define        BDB_DEL_INDEX   0x08
 #define        BDB_RE_OPEN             0x10
+#ifdef BDB_HIER
+       int             bi_modrdns;             /* number of modrdns completed */
+       ldap_pvt_thread_mutex_t bi_modrdns_mutex;
+#endif
 };
 
 #define bi_id2entry    bi_databases[BDB_ID2ENTRY]
index 126e3e615271fc9f0d6f1184559d37685e32f348..d203586cc34fea0f91831acc4cd9edb1775cf0a7 100644 (file)
@@ -972,11 +972,11 @@ bdb_cache_modify(
  */
 int
 bdb_cache_modrdn(
+       struct bdb_info *bdb,
        Entry *e,
        struct berval *nrdn,
        Entry *new,
        EntryInfo *ein,
-       DB_ENV *env,
        u_int32_t locker,
        DB_LOCK *lock )
 {
@@ -985,7 +985,7 @@ bdb_cache_modrdn(
        int rc;
 
        /* Get write lock on data */
-       rc =  bdb_cache_entry_db_relock( env, locker, ei, 1, 0, lock );
+       rc =  bdb_cache_entry_db_relock( bdb->bi_dbenv, locker, ei, 1, 0, lock );
        if ( rc ) return rc;
 
        /* If we've done repeated mods on a cached entry, then e_attrs
@@ -1030,12 +1030,11 @@ bdb_cache_modrdn(
        }
 #ifdef BDB_HIER
        {
-               int max = ei->bei_modrdns;
                /* Record the generation number of this change */
-               for ( pei = ein; pei->bei_parent; pei = pei->bei_parent ) {
-                       if ( pei->bei_modrdns > max ) max = pei->bei_modrdns;
-               }
-               ei->bei_modrdns = max + 1;
+               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 );
index d0e04377ac09abe5bd62495735af4b405a5b3c61..bfd5296266561b3a660ccec9f62136b83797727f 100644 (file)
@@ -66,6 +66,9 @@ bdb_db_init( BackendDB *be )
 
        ldap_pvt_thread_mutex_init( &bdb->bi_database_mutex );
        ldap_pvt_thread_mutex_init( &bdb->bi_lastid_mutex );
+#ifdef BDB_HIER
+       ldap_pvt_thread_mutex_init( &bdb->bi_modrdns_mutex );
+#endif
        ldap_pvt_thread_mutex_init( &bdb->bi_cache.lru_mutex );
        ldap_pvt_thread_mutex_init( &bdb->bi_cache.c_dntree.bei_kids_mutex );
        ldap_pvt_thread_rdwr_init ( &bdb->bi_cache.c_rwlock );
@@ -660,6 +663,9 @@ bdb_db_destroy( BackendDB *be )
        ldap_pvt_thread_rdwr_destroy ( &bdb->bi_cache.c_rwlock );
        ldap_pvt_thread_mutex_destroy( &bdb->bi_cache.lru_mutex );
        ldap_pvt_thread_mutex_destroy( &bdb->bi_cache.c_dntree.bei_kids_mutex );
+#ifdef BDB_HIER
+       ldap_pvt_thread_mutex_destroy( &bdb->bi_modrdns_mutex );
+#endif
        ldap_pvt_thread_mutex_destroy( &bdb->bi_lastid_mutex );
        ldap_pvt_thread_mutex_destroy( &bdb->bi_database_mutex );
        ldap_pvt_thread_rdwr_destroy( &bdb->bi_idl_tree_rwlock );
index 54c487c4507b118cf8a574c323aef8bf16dc55fd..458d17e3d5cdc84785b97f0400f3b5c136e1a540 100644 (file)
@@ -797,8 +797,8 @@ retry:      /* transaction retry */
                }
 
        } else {
-               rc = bdb_cache_modrdn( e, &op->orr_nnewrdn, &dummy, neip,
-                       bdb->bi_dbenv, locker, &lock );
+               rc = bdb_cache_modrdn( bdb, e, &op->orr_nnewrdn, &dummy, neip,
+                       locker, &lock );
                switch( rc ) {
                case DB_LOCK_DEADLOCK:
                case DB_LOCK_NOTGRANTED:
index 7d3d49b7d335a6b63ded2dc6d14338ee21733d8f..ec2dcea4ff990f15d7d913d684dffa8a4e57831f 100644 (file)
@@ -445,11 +445,11 @@ int bdb_cache_add(
        u_int32_t locker
 );
 int bdb_cache_modrdn(
+       struct bdb_info *bdb,
        Entry   *e,
        struct berval *nrdn,
        Entry   *new,
        EntryInfo *ein,
-       DB_ENV *env,
        u_int32_t locker,
        DB_LOCK *lock
 );