/* LDBM backend specific entry info -- visible only to the cache */
typedef struct ldbm_entry_info {
+#ifdef LDBM_ENTRY_RWLOCK
ldap_pvt_thread_rdwr_t lei_rdwr; /* reader/writer lock */
+#endif
/*
* remaining fields require backend cache lock to access
static void lru_print(Cache *cache);
#endif
+#ifdef LDBM_ENTRY_RWLOCK
static int
cache_entry_rdwr_lock(Entry *e, int rw)
{
{
return ldap_pvt_thread_rdwr_destroy( &LEI(e)->lei_rdwr );
}
+#endif
static int
cache_entry_private_init( Entry*e )
e->e_private = ch_calloc(1, sizeof(struct ldbm_entry_info));
+#ifdef LDBM_ENTRY_RWLOCK
if( cache_entry_rdwr_init( e ) != 0 ) {
free( LEI(e) );
e->e_private = NULL;
return 1;
}
+#endif
return 0;
}
{
assert( e->e_private );
+#ifdef LDBM_ENTRY_RWLOCK
cache_entry_rdwr_destroy( e );
+#endif
free( e->e_private );
e->e_private = NULL;
assert( e->e_private );
+#ifdef LDBM_ENTRY_RWLOCK
cache_entry_rdwr_unlock(e, rw);
+#endif
id = e->e_id;
refcnt = --LEI(e)->lei_refcnt;
e->e_id, e->e_dn, 0 );
#endif
-
-
/* delete from dn tree inserted above */
if ( avl_delete( &cache->c_dntree, (caddr_t) e,
(AVL_CMP) entry_dn_cmp ) == NULL )
Debug( LDAP_DEBUG_ANY, "====> can't delete from dn cache\n",
0, 0, 0 );
#endif
-
}
cache_entry_private_destroy(e);
return( -1 );
}
+#ifdef LDBM_ENTRY_RWLOCK
cache_entry_rdwr_lock( e, rw );
+#endif
/* put the entry into 'CREATING' state */
/* will be marked after when entry is returned */
goto try_again;
}
+#ifdef LDBM_ENTRY_RWLOCK
/* acquire reader lock */
if ( cache_entry_rdwr_trylock(ep, rw) == LDAP_PVT_THREAD_EBUSY ) {
/* could not acquire entry lock...
ldap_pvt_thread_yield();
goto try_again;
}
+#endif
/* lru */
LRU_DELETE( cache, ep );