#endif
static EntryInfo *
-bdb_cache_entryinfo_new( )
+bdb_cache_entryinfo_new( Cache *cache )
{
- EntryInfo *ei;
+ EntryInfo *ei = NULL;
- ei = ch_calloc(1, sizeof(struct bdb_entry_info));
- ldap_pvt_thread_mutex_init( &ei->bei_kids_mutex );
+ if ( cache->c_eifree ) {
+ ldap_pvt_thread_rdwr_wlock( &cache->c_rwlock );
+ if ( cache->c_eifree ) {
+ ei = cache->c_eifree;
+ cache->c_eifree = ei->bei_lrunext;
+ }
+ ldap_pvt_thread_rdwr_wunlock( &cache->c_rwlock );
+ }
+ if ( ei ) {
+ ei->bei_lrunext = NULL;
+ } else {
+ ei = ch_calloc(1, sizeof(struct bdb_entry_info));
+ ldap_pvt_thread_mutex_init( &ei->bei_kids_mutex );
+ }
return ei;
}
*res = NULL;
- ei2 = bdb_cache_entryinfo_new();
+ ei2 = bdb_cache_entryinfo_new( &bdb->bi_cache );
ldap_pvt_thread_rdwr_wlock( &bdb->bi_cache.c_rwlock );
bdb_cache_entryinfo_lock( ei->bei_parent );
ei2 = ein;
/* Create a new node for the current ID */
- ein = bdb_cache_entryinfo_new();
+ ein = bdb_cache_entryinfo_new( &bdb->bi_cache );
ein->bei_id = ei.bei_id;
ein->bei_kids = ei.bei_kids;
ein->bei_nrdn = ei.bei_nrdn;
void
bdb_cache_delete_cleanup(
+ Cache *cache,
Entry *e
)
{
- bdb_cache_entryinfo_unlock( BEI(e) );
- bdb_cache_entryinfo_destroy( e->e_private );
+ EntryInfo *ei = BEI(e);
+
+ ei->bei_e = NULL;
e->e_private = NULL;
bdb_entry_return( e );
+
+ free( ei->bei_nrdn.bv_val );
+ ei->bei_nrdn.bv_val = NULL;
+#ifdef BDB_HIER
+ free( ei->bei_rdn.bv_val );
+ ei->bei_rdn.bv_val = NULL;
+ ei->bei_modrdns = 0;
+ ei->bei_ckids = 0;
+ ei->bei_dkids = 0;
+#endif
+ ei->bei_parent = NULL;
+ ei->bei_kids = NULL;
+ ei->bei_lruprev = NULL;
+
+ ldap_pvt_thread_rdwr_wlock( &cache->c_rwlock );
+ ei->bei_lrunext = cache->c_eifree;
+ cache->c_eifree = ei;
+ ldap_pvt_thread_rdwr_wunlock( &cache->c_rwlock );
+ bdb_cache_entryinfo_unlock( ei );
}
-
+
static int
bdb_cache_delete_internal(
Cache *cache,
DB_LOCK *lock )
{
ldap_pvt_thread_rdwr_wlock( &bdb->bi_cache.c_rwlock );
- if ( bdb_cache_entry_db_lock( bdb->bi_dbenv, locker, ei, 1, 1, &lock ) == 0 ) {
+ if ( bdb_cache_entry_db_lock( bdb->bi_dbenv, locker, ei, 1, 1, lock ) == 0 ) {
if ( ei->bei_e && !(ei->bei_state & CACHE_ENTRY_NOT_LINKED )) {
LRU_DELETE( &bdb->bi_cache, ei );
ei->bei_e->e_private = NULL;
ei->bei_e = NULL;
--bdb->bi_cache.c_cursize;
}
- bdb_cache_entry_db_unlock( bdb->bi_dbenv, &lock );
+ bdb_cache_entry_db_unlock( bdb->bi_dbenv, lock );
}
ldap_pvt_thread_rdwr_wunlock( &bdb->bi_cache.c_rwlock );
}