]> git.sur5r.net Git - openldap/commitdiff
Fix idl_cache teardown again - skip if cache is empty
authorHoward Chu <hyc@openldap.org>
Thu, 4 Jan 2007 03:14:46 +0000 (03:14 +0000)
committerHoward Chu <hyc@openldap.org>
Thu, 4 Jan 2007 03:14:46 +0000 (03:14 +0000)
servers/slapd/back-bdb/init.c

index 018a741421a3f275e151400a3e76d6700a2b4aaf..8d8df564fd320bc5ae8c094c82831565462483a6 100644 (file)
@@ -71,8 +71,7 @@ bdb_db_init( BackendDB *be )
 #ifdef BDB_HIER
        ldap_pvt_thread_mutex_init( &bdb->bi_modrdns_mutex );
 #endif
-       ldap_pvt_thread_mutex_init( &bdb->bi_cache.lru_head_mutex );
-       ldap_pvt_thread_mutex_init( &bdb->bi_cache.lru_tail_mutex );
+       ldap_pvt_thread_mutex_init( &bdb->bi_cache.lru_mutex );
        ldap_pvt_thread_mutex_init( &bdb->bi_cache.c_count_mutex );
        ldap_pvt_thread_mutex_init( &bdb->bi_cache.c_eifree_mutex );
        ldap_pvt_thread_mutex_init( &bdb->bi_cache.c_dntree.bei_kids_mutex );
@@ -476,16 +475,18 @@ bdb_db_close( BackendDB *be )
        if ( bdb->bi_idl_cache_max_size ) {
                avl_free( bdb->bi_idl_tree, NULL );
                bdb->bi_idl_tree = NULL;
-               entry = bdb->bi_idl_lru_head;
-               do {
-                       next_entry = entry->idl_lru_next;
-                       if ( entry->idl )
-                               free( entry->idl );
-                       free( entry->kstr.bv_val );
-                       free( entry );
-                       entry = next_entry;
-               } while ( entry != bdb->bi_idl_lru_head );
-               bdb->bi_idl_lru_head = bdb->bi_idl_lru_tail = NULL;
+               if ( bdb->bi_idl_lru_head ) {
+                       entry = bdb->bi_idl_lru_head;
+                       do {
+                               next_entry = entry->idl_lru_next;
+                               if ( entry->idl )
+                                       free( entry->idl );
+                               free( entry->kstr.bv_val );
+                               free( entry );
+                               entry = next_entry;
+                       } while ( entry != bdb->bi_idl_lru_head );
+                       bdb->bi_idl_lru_head = bdb->bi_idl_lru_tail = NULL;
+               }
        }
 
        /* close db environment */
@@ -542,8 +543,7 @@ bdb_db_destroy( BackendDB *be )
        bdb_attr_index_destroy( bdb );
 
        ldap_pvt_thread_rdwr_destroy ( &bdb->bi_cache.c_rwlock );
-       ldap_pvt_thread_mutex_destroy( &bdb->bi_cache.lru_head_mutex );
-       ldap_pvt_thread_mutex_destroy( &bdb->bi_cache.lru_tail_mutex );
+       ldap_pvt_thread_mutex_destroy( &bdb->bi_cache.lru_mutex );
        ldap_pvt_thread_mutex_destroy( &bdb->bi_cache.c_count_mutex );
        ldap_pvt_thread_mutex_destroy( &bdb->bi_cache.c_eifree_mutex );
        ldap_pvt_thread_mutex_destroy( &bdb->bi_cache.c_dntree.bei_kids_mutex );