]> git.sur5r.net Git - openldap/commitdiff
Cleanup db_close vs db_destroy steps
authorHoward Chu <hyc@openldap.org>
Fri, 22 Apr 2005 18:07:02 +0000 (18:07 +0000)
committerHoward Chu <hyc@openldap.org>
Fri, 22 Apr 2005 18:07:02 +0000 (18:07 +0000)
servers/slapd/back-bdb/cache.c
servers/slapd/back-bdb/init.c

index 1f2f7a3b5ab3caf6bd5e06fc05859273f89e5dcc..126e3e615271fc9f0d6f1184559d37685e32f348 100644 (file)
@@ -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 );
index c27d20c870d1eac13a67011e9c91525b13873266..755d4194362b587f2e4524246eb59605ca0fc601 100644 (file)
@@ -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 );