/* BDB backend specific entry info -- visible only to the cache */
typedef struct bdb_entry_info {
+#if 0
ldap_pvt_thread_rdwr_t bei_rdwr; /* reader/writer lock */
+#endif
/*
* remaining fields require backend cache lock to access
}
#endif /* unused */
+#if 0
static int
bdb_cache_entry_rdwr_init(Entry *e)
{
{
return ldap_pvt_thread_rdwr_destroy( &BEI(e)->bei_rdwr );
}
+#endif
static int
bdb_cache_entry_private_init( Entry *e )
e->e_private = ch_calloc(1, sizeof(struct bdb_entry_info));
+#if 0
if( bdb_cache_entry_rdwr_init( e ) != 0 ) {
free( BEI(e) );
e->e_private = NULL;
return 1;
}
+#endif
return 0;
}
else
db_rw = DB_LOCK_READ;
+#if 0
lockobj.data = e->e_nname.bv_val;
lockobj.size = e->e_nname.bv_len;
+#else
+ lockobj.data = &e->e_private;
+ lockobj.size = sizeof(e->e_private);
+#endif
rc = LOCK_GET(env, locker, flags | DB_LOCK_NOWAIT,
&lockobj, db_rw, lock);
if (rc) {
{
assert( e->e_private );
+#if 0
bdb_cache_entry_rdwr_destroy( e );
+#endif
free( e->e_private );
e->e_private = NULL;
/*
* entry is deleted or not fully created yet
*/
- if ( state != CACHE_ENTRY_READY ) {
+ if ( state != CACHE_ENTRY_READY && state != CACHE_ENTRY_COMMITTED ) {
assert(state != CACHE_ENTRY_UNDEFINED);
/* free cache read lock */
/*
* entry is deleted or not fully created yet
*/
- if ( state != CACHE_ENTRY_READY ) {
+ if ( state != CACHE_ENTRY_READY && state != CACHE_ENTRY_COMMITTED ) {
assert(state != CACHE_ENTRY_UNDEFINED);
{
int i, rc, lockid;
void *data;
+ void *ctx;
- if ( !env || !op || !locker ) return -1;
+ if ( !env || !locker ) return -1;
+
+ /* If no op was provided, try to find the ctx anyway... */
+ if ( op ) {
+ ctx = op->o_threadctx;
+ } else {
+ ctx = ldap_pvt_thread_pool_context();
+ }
/* Shouldn't happen unless we're single-threaded */
- if ( !op->o_threadctx ) {
+ if ( !ctx ) {
*locker = 0;
return 0;
}
- if ( ldap_pvt_thread_pool_getkey( op->o_threadctx, env, &data, NULL ) ) {
+ if ( ldap_pvt_thread_pool_getkey( ctx, env, &data, NULL ) ) {
for ( i=0, rc=1; rc != 0 && i<4; i++ ) {
rc = XLOCK_ID( env, &lockid );
if (rc) ldap_pvt_thread_yield();
return rc;
}
data = (void *)lockid;
- if ( ( rc = ldap_pvt_thread_pool_setkey( op->o_threadctx, env,
+ if ( ( rc = ldap_pvt_thread_pool_setkey( ctx, env,
data, bdb_locker_id_free ) ) ) {
XLOCK_ID_FREE( env, lockid );
#ifdef NEW_LOGGING