From: Howard Chu Date: Fri, 22 Apr 2005 18:07:02 +0000 (+0000) Subject: Cleanup db_close vs db_destroy steps X-Git-Tag: OPENLDAP_AC_BP~828 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=c49ba400db632709bafb96b8e8f5d5d702727048;p=openldap Cleanup db_close vs db_destroy steps --- diff --git a/servers/slapd/back-bdb/cache.c b/servers/slapd/back-bdb/cache.c index 1f2f7a3b5a..126e3e6152 100644 --- a/servers/slapd/back-bdb/cache.c +++ b/servers/slapd/back-bdb/cache.c @@ -1207,8 +1207,12 @@ bdb_cache_release_all( Cache *cache ) cache->c_lruhead = cache->c_eifree->bei_lrunext; bdb_cache_entryinfo_destroy(cache->c_eifree); } + cache->c_cursize = 0; + cache->c_eiused = 0; + cache->c_idtree = NULL; cache->c_lruhead = NULL; cache->c_lrutail = NULL; + cache->c_dntree.bei_kids = NULL; /* free lru mutex */ ldap_pvt_thread_mutex_unlock( &cache->lru_mutex ); diff --git a/servers/slapd/back-bdb/init.c b/servers/slapd/back-bdb/init.c index c27d20c870..755d419436 100644 --- a/servers/slapd/back-bdb/init.c +++ b/servers/slapd/back-bdb/init.c @@ -563,6 +563,7 @@ bdb_db_close( BackendDB *be ) bdb->bi_flags &= ~BDB_IS_OPEN; ber_bvarray_free( bdb->bi_db_config ); + bdb->bi_db_config = NULL; while( bdb->bi_ndatabases-- ) { db = bdb->bi_databases[bdb->bi_ndatabases]; @@ -573,13 +574,17 @@ bdb_db_close( BackendDB *be ) free( db ); } free( bdb->bi_databases ); + bdb->bi_databases = NULL; + bdb_attr_index_destroy( bdb->bi_attrs ); + bdb->bi_attrs = NULL; bdb_cache_release_all (&bdb->bi_cache); if ( bdb->bi_idl_cache_max_size ) { ldap_pvt_thread_rdwr_wlock ( &bdb->bi_idl_tree_rwlock ); avl_free( bdb->bi_idl_tree, NULL ); + bdb->bi_idl_tree = NULL; entry = bdb->bi_idl_lru_head; while ( entry != NULL ) { next_entry = entry->idl_lru_next; @@ -589,22 +594,15 @@ bdb_db_close( BackendDB *be ) free( entry ); entry = next_entry; } + bdb->bi_idl_lru_head = bdb->bi_idl_lru_tail = NULL; ldap_pvt_thread_rdwr_wunlock ( &bdb->bi_idl_tree_rwlock ); } if ( !( slapMode & SLAP_TOOL_QUICK ) && bdb->bi_dbenv ) { XLOCK_ID_FREE(bdb->bi_dbenv, bdb->bi_cache.c_locker); + bdb->bi_cache.c_locker = 0; } - return 0; -} - -static int -bdb_db_destroy( BackendDB *be ) -{ - int rc; - struct bdb_info *bdb = (struct bdb_info *) be->be_private; - /* close db environment */ if( bdb->bi_dbenv ) { /* force a checkpoint */ @@ -612,7 +610,7 @@ bdb_db_destroy( BackendDB *be ) rc = TXN_CHECKPOINT( bdb->bi_dbenv, 0, 0, DB_FORCE ); if( rc != 0 ) { Debug( LDAP_DEBUG_ANY, - "bdb_db_destroy: txn_checkpoint failed: %s (%d)\n", + "bdb_db_close: txn_checkpoint failed: %s (%d)\n", db_strerror(rc), rc, 0 ); } } @@ -621,7 +619,7 @@ bdb_db_destroy( BackendDB *be ) bdb->bi_dbenv = NULL; if( rc != 0 ) { Debug( LDAP_DEBUG_ANY, - "bdb_db_destroy: close failed: %s (%d)\n", + "bdb_db_close: close failed: %s (%d)\n", db_strerror(rc), rc, 0 ); return rc; } @@ -630,10 +628,19 @@ bdb_db_destroy( BackendDB *be ) rc = alock_close( &bdb->bi_alock_info ); if( rc != 0 ) { Debug( LDAP_DEBUG_ANY, - "bdb_db_destroy: alock_close failed\n", 0, 0, 0 ); + "bdb_db_close: alock_close failed\n", 0, 0, 0 ); return -1; } + return 0; +} + +static int +bdb_db_destroy( BackendDB *be ) +{ + int rc; + struct bdb_info *bdb = (struct bdb_info *) be->be_private; + if( bdb->bi_dbenv_home ) ch_free( bdb->bi_dbenv_home ); if( bdb->bi_db_config_path ) ch_free( bdb->bi_db_config_path );