/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
- * Copyright 2000-2006 The OpenLDAP Foundation.
+ * Copyright 2000-2007 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
#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.c_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 );
goto fail;
}
+ if ( !quick ) {
+ XLOCK_ID(bdb->bi_dbenv, &bdb->bi_cache.c_locker);
+ }
+
/* monitor setup */
rc = bdb_monitor_db_open( be );
if ( rc != 0 ) {
bdb_cache_release_all (&bdb->bi_cache);
- if ( bdb->bi_idl_cache_max_size ) {
+ if ( bdb->bi_idl_cache_size ) {
avl_free( bdb->bi_idl_tree, NULL );
bdb->bi_idl_tree = NULL;
entry = bdb->bi_idl_lru_head;
- while ( entry != NULL ) {
+ 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 */
if( bdb->bi_dbenv ) {
+ /* Free cache locker if we enabled locking */
+ if ( !( slapMode & SLAP_TOOL_QUICK )) {
+ XLOCK_ID_FREE(bdb->bi_dbenv, bdb->bi_cache.c_locker);
+ bdb->bi_cache.c_locker = 0;
+ }
+
/* force a checkpoint, but not if we were ReadOnly,
* and not in Quick mode since there are no transactions there.
*/
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.c_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 );