From: Howard Chu Date: Tue, 12 Jul 2005 13:17:56 +0000 (+0000) Subject: ITS#3857 fix bottom-up modrdn cascades, use a global modrdn counter. X-Git-Tag: OPENLDAP_AC_BP~415 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=fbbfac677184b6f18991d0c558e174feedd69e2d;p=openldap ITS#3857 fix bottom-up modrdn cascades, use a global modrdn counter. --- diff --git a/servers/slapd/back-bdb/back-bdb.h b/servers/slapd/back-bdb/back-bdb.h index dea33f671d..d6e9ecc20d 100644 --- a/servers/slapd/back-bdb/back-bdb.h +++ b/servers/slapd/back-bdb/back-bdb.h @@ -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] diff --git a/servers/slapd/back-bdb/cache.c b/servers/slapd/back-bdb/cache.c index 126e3e6152..d203586cc3 100644 --- a/servers/slapd/back-bdb/cache.c +++ b/servers/slapd/back-bdb/cache.c @@ -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 ); diff --git a/servers/slapd/back-bdb/init.c b/servers/slapd/back-bdb/init.c index d0e04377ac..bfd5296266 100644 --- a/servers/slapd/back-bdb/init.c +++ b/servers/slapd/back-bdb/init.c @@ -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 ); diff --git a/servers/slapd/back-bdb/modrdn.c b/servers/slapd/back-bdb/modrdn.c index 54c487c450..458d17e3d5 100644 --- a/servers/slapd/back-bdb/modrdn.c +++ b/servers/slapd/back-bdb/modrdn.c @@ -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: diff --git a/servers/slapd/back-bdb/proto-bdb.h b/servers/slapd/back-bdb/proto-bdb.h index 7d3d49b7d3..ec2dcea4ff 100644 --- a/servers/slapd/back-bdb/proto-bdb.h +++ b/servers/slapd/back-bdb/proto-bdb.h @@ -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 );