mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-12-29 02:59:34 -05:00
Cleanup db_close vs db_destroy steps
This commit is contained in:
parent
e7462c7bda
commit
c49ba400db
2 changed files with 40 additions and 29 deletions
|
|
@ -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 );
|
||||
|
|
|
|||
|
|
@ -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,11 +594,42 @@ 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;
|
||||
}
|
||||
|
||||
/* close db environment */
|
||||
if( bdb->bi_dbenv ) {
|
||||
/* force a checkpoint */
|
||||
if ( !( slapMode & SLAP_TOOL_QUICK )) {
|
||||
rc = TXN_CHECKPOINT( bdb->bi_dbenv, 0, 0, DB_FORCE );
|
||||
if( rc != 0 ) {
|
||||
Debug( LDAP_DEBUG_ANY,
|
||||
"bdb_db_close: txn_checkpoint failed: %s (%d)\n",
|
||||
db_strerror(rc), rc, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
rc = bdb->bi_dbenv->close( bdb->bi_dbenv, 0 );
|
||||
bdb->bi_dbenv = NULL;
|
||||
if( rc != 0 ) {
|
||||
Debug( LDAP_DEBUG_ANY,
|
||||
"bdb_db_close: close failed: %s (%d)\n",
|
||||
db_strerror(rc), rc, 0 );
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
|
||||
rc = alock_close( &bdb->bi_alock_info );
|
||||
if( rc != 0 ) {
|
||||
Debug( LDAP_DEBUG_ANY,
|
||||
"bdb_db_close: alock_close failed\n", 0, 0, 0 );
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
@ -605,35 +641,6 @@ 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 */
|
||||
if ( !( slapMode & SLAP_TOOL_QUICK )) {
|
||||
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",
|
||||
db_strerror(rc), rc, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
rc = bdb->bi_dbenv->close( bdb->bi_dbenv, 0 );
|
||||
bdb->bi_dbenv = NULL;
|
||||
if( rc != 0 ) {
|
||||
Debug( LDAP_DEBUG_ANY,
|
||||
"bdb_db_destroy: close failed: %s (%d)\n",
|
||||
db_strerror(rc), rc, 0 );
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
|
||||
rc = alock_close( &bdb->bi_alock_info );
|
||||
if( rc != 0 ) {
|
||||
Debug( LDAP_DEBUG_ANY,
|
||||
"bdb_db_destroy: alock_close failed\n", 0, 0, 0 );
|
||||
return -1;
|
||||
}
|
||||
|
||||
if( bdb->bi_dbenv_home ) ch_free( bdb->bi_dbenv_home );
|
||||
if( bdb->bi_db_config_path ) ch_free( bdb->bi_db_config_path );
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue