if( p ) {
/* free parent and reader lock */
if ( p != (Entry *)&slap_entry_root ) {
- bdb_unlocked_cache_return_entry_r( &bdb->bi_cache, p );
+ bdb_unlocked_cache_return_entry_r( bdb, p );
}
p = NULL;
}
rs->sr_ref = is_entry_referral( p )
? get_entry_referrals( op, p )
: NULL;
- bdb_unlocked_cache_return_entry_r( &bdb->bi_cache, p );
+ bdb_unlocked_cache_return_entry_r( bdb, p );
p = NULL;
Debug( LDAP_DEBUG_TRACE,
LDAP_XSTRING(bdb_add) ": parent "
rs->sr_matched = ber_strdup_x( p->e_name.bv_val,
op->o_tmpmemctx );
rs->sr_ref = get_entry_referrals( op, p );
- bdb_unlocked_cache_return_entry_r( &bdb->bi_cache, p );
+ bdb_unlocked_cache_return_entry_r( bdb, p );
p = NULL;
Debug( LDAP_DEBUG_TRACE,
LDAP_XSTRING(bdb_add) ": parent is referral\n",
/* free parent and reader lock */
if ( p != (Entry *)&slap_entry_root ) {
- bdb_unlocked_cache_return_entry_r( &bdb->bi_cache, p );
+ bdb_unlocked_cache_return_entry_r( bdb, p );
}
p = NULL;
* Possibly a callback may have mucked with it, although
* in general callbacks should treat the entry as read-only.
*/
- bdb_cache_return_entry_r( bdb->bi_dbenv, &bi->bi_cache, oe, &lock );
+ bdb_cache_return_entry_r( bdb, oe, &lock );
if ( op->ora_e == oe )
op->ora_e = NULL;
e = ei->bei_e;
if ( rs->sr_err == DB_NOTFOUND ) {
if( e != NULL ) {
- bdb_cache_return_entry_r( bdb->bi_dbenv,
- &bdb->bi_cache, e, &lock );
+ bdb_cache_return_entry_r( bdb, e, &lock );
e = NULL;
}
done:
/* free entry and reader lock */
if( e != NULL ) {
- bdb_cache_return_entry_r( bdb->bi_dbenv, &bdb->bi_cache, e, &lock );
+ bdb_cache_return_entry_r( bdb, e, &lock );
}
LOCK_ID_FREE(bdb->bi_dbenv, locker);
/* Atomically release and reacquire a lock */
int
bdb_cache_entry_db_relock(
- DB_ENV *env,
+ struct bdb_info *bdb,
u_int32_t locker,
EntryInfo *ei,
int rw,
list[1].lock = *lock;
list[1].mode = rw ? DB_LOCK_WRITE : DB_LOCK_READ;
list[1].obj = &lockobj;
- rc = env->lock_vec(env, locker, tryOnly ? DB_LOCK_NOWAIT : 0,
+ rc = bdb->bi_dbenv->lock_vec(bdb->bi_dbenv, locker, tryOnly ? DB_LOCK_NOWAIT : 0,
list, 2, NULL );
if (rc && !tryOnly) {
}
static int
-bdb_cache_entry_db_lock( DB_ENV *env, u_int32_t locker, EntryInfo *ei,
+bdb_cache_entry_db_lock( struct bdb_info *bdb, u_int32_t locker, EntryInfo *ei,
int rw, int tryOnly, DB_LOCK *lock )
{
#ifdef NO_DB_LOCK
lockobj.data = &ei->bei_id;
lockobj.size = sizeof(ei->bei_id) + 1;
- rc = LOCK_GET(env, locker, tryOnly ? DB_LOCK_NOWAIT : 0,
+ rc = LOCK_GET(bdb->bi_dbenv, locker, tryOnly ? DB_LOCK_NOWAIT : 0,
&lockobj, db_rw, lock);
if (rc && !tryOnly) {
Debug( LDAP_DEBUG_TRACE,
}
int
-bdb_cache_entry_db_unlock ( DB_ENV *env, DB_LOCK *lock )
+bdb_cache_entry_db_unlock ( struct bdb_info *bdb, DB_LOCK *lock )
{
#ifdef NO_DB_LOCK
return 0;
if ( !lock || lock->mode == DB_LOCK_NG ) return 0;
- rc = LOCK_PUT ( env, lock );
+ rc = LOCK_PUT ( bdb->bi_dbenv, lock );
return rc;
#endif
}
bdb_cache_entryinfo_unlock( *eip );
islocked = 0;
}
- rc = bdb_cache_entry_db_lock( bdb->bi_dbenv, locker, *eip, 0, 0, lock );
+ rc = bdb_cache_entry_db_lock( bdb, locker, *eip, 0, 0, lock );
if ( (*eip)->bei_state & CACHE_ENTRY_DELETED ) {
rc = DB_NOTFOUND;
- bdb_cache_entry_db_unlock( bdb->bi_dbenv, lock );
+ bdb_cache_entry_db_unlock( bdb, lock );
} else if ( rc == 0 ) {
if ( load ) {
/* Give up original read lock, obtain write lock
*/
if ( rc == 0 ) {
- rc = bdb_cache_entry_db_relock( bdb->bi_dbenv, locker,
+ rc = bdb_cache_entry_db_relock( bdb, locker,
*eip, 1, 0, lock );
}
if ( rc == 0 && !ep) {
bdb_cache_entryinfo_unlock( *eip );
if ( rc == 0 ) {
/* If we succeeded, downgrade back to a readlock. */
- rc = bdb_cache_entry_db_relock( bdb->bi_dbenv, locker,
+ rc = bdb_cache_entry_db_relock( bdb, locker,
*eip, 0, 0, lock );
} else {
/* Otherwise, release the lock. */
- bdb_cache_entry_db_unlock( bdb->bi_dbenv, lock );
+ bdb_cache_entry_db_unlock( bdb, lock );
}
} else if ( !(*eip)->bei_e ) {
/* Some other thread is trying to load the entry,
- * give it a chance to finish.
+ * wait for it to finish.
*/
- bdb_cache_entry_db_unlock( bdb->bi_dbenv, lock );
- ldap_pvt_thread_yield();
+ bdb_cache_entry_db_unlock( bdb, lock );
bdb_cache_entryinfo_lock( *eip );
islocked = 1;
goto load1;
*/
rc = bdb_fix_dn( (*eip)->bei_e, 1 );
if ( rc ) {
- bdb_cache_entry_db_relock( bdb->bi_dbenv,
+ bdb_cache_entry_db_relock( bdb,
locker, *eip, 1, 0, lock );
/* check again in case other modifier did it already */
if ( bdb_fix_dn( (*eip)->bei_e, 1 ) )
rc = bdb_fix_dn( (*eip)->bei_e, 2 );
- bdb_cache_entry_db_relock( bdb->bi_dbenv,
+ bdb_cache_entry_db_relock( bdb,
locker, *eip, 0, 0, lock );
}
#endif
/* Lock this entry so that bdb_add can run to completion.
* It can only fail if BDB has run out of lock resources.
*/
- rc = bdb_cache_entry_db_lock( bdb->bi_dbenv, locker, &ei, 0, 0, lock );
+ rc = bdb_cache_entry_db_lock( bdb, locker, &ei, 0, 0, lock );
if ( rc ) {
bdb_cache_entryinfo_unlock( eip );
return rc;
int
bdb_cache_modify(
+ struct bdb_info *bdb,
Entry *e,
Attribute *newAttrs,
- DB_ENV *env,
u_int32_t locker,
DB_LOCK *lock )
{
EntryInfo *ei = BEI(e);
int rc;
/* Get write lock on data */
- rc = bdb_cache_entry_db_relock( env, locker, ei, 1, 0, lock );
+ rc = bdb_cache_entry_db_relock( bdb, locker, ei, 1, 0, lock );
/* If we've done repeated mods on a cached entry, then e_attrs
* is no longer contiguous with the entry, and must be freed.
#endif
/* Get write lock on data */
- rc = bdb_cache_entry_db_relock( bdb->bi_dbenv, locker, ei, 1, 0, lock );
+ rc = bdb_cache_entry_db_relock( bdb, locker, ei, 1, 0, lock );
if ( rc ) return rc;
/* If we've done repeated mods on a cached entry, then e_attrs
*/
int
bdb_cache_delete(
- Cache *cache,
+ struct bdb_info *bdb,
Entry *e,
- DB_ENV *env,
u_int32_t locker,
DB_LOCK *lock )
{
bdb_cache_entryinfo_lock( ei );
/* Get write lock on the data */
- rc = bdb_cache_entry_db_relock( env, locker, ei, 1, 0, lock );
+ rc = bdb_cache_entry_db_relock( bdb, locker, ei, 1, 0, lock );
if ( rc ) {
/* couldn't lock, undo and give up */
ei->bei_state ^= CACHE_ENTRY_DELETED;
e->e_id, 0, 0 );
/* set lru mutex */
- ldap_pvt_thread_mutex_lock( &cache->lru_head_mutex );
+ ldap_pvt_thread_mutex_lock( &bdb->bi_cache.lru_head_mutex );
- rc = bdb_cache_delete_internal( cache, e->e_private, 1 );
+ rc = bdb_cache_delete_internal( &bdb->bi_cache, e->e_private, 1 );
/* free lru mutex */
- ldap_pvt_thread_mutex_unlock( &cache->lru_head_mutex );
+ ldap_pvt_thread_mutex_unlock( &bdb->bi_cache.lru_head_mutex );
/* Leave entry info locked */
rs->sr_err = LDAP_REFERRAL;
}
- bdb_cache_return_entry_r( bdb->bi_dbenv, &bdb->bi_cache, e, &lock );
+ bdb_cache_return_entry_r( bdb, e, &lock );
e = NULL;
} else {
done:
/* free entry */
if ( e != NULL ) {
- bdb_cache_return_entry_r( bdb->bi_dbenv, &bdb->bi_cache,
- e, &lock );
+ bdb_cache_return_entry_r( bdb, e, &lock );
}
LOCK_ID_FREE ( bdb->bi_dbenv, locker );
goto return_results;
}
} else {
- rc = bdb_cache_delete( &bdb->bi_cache, e, bdb->bi_dbenv,
- locker, &lock );
+ rc = bdb_cache_delete( bdb, e, locker, &lock );
switch( rc ) {
case DB_LOCK_DEADLOCK:
case DB_LOCK_NOTGRANTED:
/* lock is freed with txn */
if ( !boi || boi->boi_txn ) {
- bdb_unlocked_cache_return_entry_rw( &bdb->bi_cache, e, rw );
+ bdb_unlocked_cache_return_entry_rw( bdb, e, rw );
} else {
struct bdb_lock_info *bli, *prev;
for ( prev=(struct bdb_lock_info *)&boi->boi_locks,
bli = boi->boi_locks; bli; prev=bli, bli=bli->bli_next ) {
if ( bli->bli_id == e->e_id ) {
- bdb_cache_return_entry_rw( bdb->bi_dbenv, &bdb->bi_cache,
- e, rw, &bli->bli_lock );
+ bdb_cache_return_entry_rw( bdb, e, rw, &bli->bli_lock );
prev->bli_next = bli->bli_next;
op->o_tmpfree( bli, op->o_tmpmemctx );
break;
return_results:
if( rc != LDAP_SUCCESS ) {
/* free entry */
- bdb_cache_return_entry_rw(bdb->bi_dbenv, &bdb->bi_cache, e, rw, &lock);
+ bdb_cache_return_entry_rw(bdb, e, rw, &lock);
} else {
if ( slapMode == SLAP_SERVER_MODE ) {
}
} else {
*ent = entry_dup( e );
- bdb_cache_return_entry_rw(bdb->bi_dbenv, &bdb->bi_cache, e, rw, &lock);
+ bdb_cache_return_entry_rw(bdb, e, rw, &lock);
}
}
attrs_free( dummy.e_attrs );
} else {
- rc = bdb_cache_modify( e, dummy.e_attrs, bdb->bi_dbenv, locker, &lock );
+ rc = bdb_cache_modify( bdb, e, dummy.e_attrs, locker, &lock );
switch( rc ) {
case DB_LOCK_DEADLOCK:
case DB_LOCK_NOTGRANTED:
* and we can trim out all of this stuff.
*/
#if 0
-void bdb_cache_return_entry_rw( DB_ENV *env, Cache *cache, Entry *e,
+void bdb_cache_return_entry_rw( struct bdb_info *bdb, Entry *e,
int rw, DB_LOCK *lock );
#else
-#define bdb_cache_return_entry_rw( env, cache, e, rw, lock ) \
- bdb_cache_entry_db_unlock( env, lock )
-#define bdb_cache_return_entry( env, lock ) \
- bdb_cache_entry_db_unlock( env, lock )
+#define bdb_cache_return_entry_rw( bdb, e, rw, lock ) \
+ bdb_cache_entry_db_unlock( bdb, lock )
+#define bdb_cache_return_entry( bdb, lock ) \
+ bdb_cache_entry_db_unlock( bdb, lock )
#endif
-#define bdb_cache_return_entry_r(env, c, e, l) \
- bdb_cache_return_entry_rw((env), (c), (e), 0, (l))
-#define bdb_cache_return_entry_w(env, c, e, l) \
- bdb_cache_return_entry_rw((env), (c), (e), 1, (l))
+#define bdb_cache_return_entry_r(bdb, e, l) \
+ bdb_cache_return_entry_rw((bdb), (e), 0, (l))
+#define bdb_cache_return_entry_w(bdb, e, l) \
+ bdb_cache_return_entry_rw((bdb), (e), 1, (l))
#if 0
-void bdb_unlocked_cache_return_entry_rw( Cache *cache, Entry *e, int rw );
+void bdb_unlocked_cache_return_entry_rw( struct bdb_info *bdb, Entry *e, int rw );
#else
#define bdb_unlocked_cache_return_entry_rw( a, b, c ) ((void)0)
#endif
DB_LOCK *lock
);
int bdb_cache_modify(
+ struct bdb_info *bdb,
Entry *e,
Attribute *newAttrs,
- DB_ENV *env,
u_int32_t locker,
DB_LOCK *lock
);
EntryInfo **res
);
int bdb_cache_delete(
- Cache *cache,
+ struct bdb_info *bdb,
Entry *e,
- DB_ENV *env,
u_int32_t locker,
DB_LOCK *lock
);
EntryInfo *ei
);
void bdb_cache_release_all( Cache *cache );
-void bdb_cache_delete_entry(
- struct bdb_info *bdb,
- EntryInfo *ei,
- u_int32_t locker,
- DB_LOCK *lock
-);
#ifdef BDB_HIER
int hdb_cache_load(
#define bdb_cache_entry_db_relock BDB_SYMBOL(cache_entry_db_relock)
int bdb_cache_entry_db_relock(
- DB_ENV *env,
+ struct bdb_info *bdb,
u_int32_t locker,
EntryInfo *ei,
int rw,
DB_LOCK *lock );
int bdb_cache_entry_db_unlock(
- DB_ENV *env,
+ struct bdb_info *bdb,
DB_LOCK *lock );
#ifdef BDB_REUSE_LOCKERS
}
}
- bdb_cache_return_entry_r (bdb->bi_dbenv, &bdb->bi_cache, e, &lock);
+ bdb_cache_return_entry_r (bdb, e, &lock);
e = NULL;
} else if ( !be_issuffix( op->o_bd, &op->o_req_ndn ) && default_referral != NULL ) {
rc = LDAP_OTHER;
ber_bvarray_free( refs );
}
- bdb_cache_return_entry_r(bdb->bi_dbenv, &bdb->bi_cache, e, &lock);
+ bdb_cache_return_entry_r(bdb, e, &lock);
LOCK_ID_FREE ( bdb->bi_dbenv, locker );
return rc;
}
/* Free the previous entry, continue to work with the
* one we just retrieved.
*/
- bdb_cache_return_entry_r( bdb->bi_dbenv, &bdb->bi_cache,
- *matched, lock);
+ bdb_cache_return_entry_r( bdb, *matched, lock);
*lock = lockr;
/* We found a regular entry. Return this to the caller. The
if (first) {
first = 0;
} else {
- bdb_cache_return_entry_r (bdb->bi_dbenv, &bdb->bi_cache, e, &locka);
+ bdb_cache_return_entry_r (bdb, e, &locka);
}
BDB_IDL_CPY(subscop2, subscop);
rs->sr_err = bdb_idl_intersection(curscop, subscop);
* turned into a range that spans IDs indiscriminately
*/
if (!is_entry_alias(a)) {
- bdb_cache_return_entry_r (bdb->bi_dbenv, &bdb->bi_cache,
- a, &lockr);
+ bdb_cache_return_entry_r (bdb, a, &lockr);
continue;
}
bdb_idl_insert(newsubs, a->e_id);
bdb_idl_insert(scopes, a->e_id);
}
- bdb_cache_return_entry_r( bdb->bi_dbenv, &bdb->bi_cache,
- a, &lockr);
+ bdb_cache_return_entry_r( bdb, a, &lockr);
} else if (matched) {
/* Alias could not be dereferenced, or it deref'd to
* an ID we've already seen. Ignore it.
*/
- bdb_cache_return_entry_r( bdb->bi_dbenv, &bdb->bi_cache,
- matched, &lockr );
+ bdb_cache_return_entry_r( bdb, matched, &lockr );
rs->sr_text = NULL;
}
}
if ( e ) {
build_new_dn( &op->o_req_ndn, &e->e_nname, &stub,
op->o_tmpmemctx );
- bdb_cache_return_entry_r (bdb->bi_dbenv, &bdb->bi_cache,
- e, &lock);
+ bdb_cache_return_entry_r (bdb, e, &lock);
matched = NULL;
goto dn2entry_retry;
}
#ifdef SLAP_ZONE_ALLOC
slap_zn_runlock(bdb->bi_cache.c_zctx, matched);
#endif
- bdb_cache_return_entry_r (bdb->bi_dbenv, &bdb->bi_cache,
- matched, &lock);
+ bdb_cache_return_entry_r (bdb, matched, &lock);
matched = NULL;
if ( erefs ) {
slap_zn_runlock(bdb->bi_cache.c_zctx, e);
#endif
if ( e != &e_root ) {
- bdb_cache_return_entry_r(bdb->bi_dbenv, &bdb->bi_cache, e, &lock);
+ bdb_cache_return_entry_r(bdb, e, &lock);
}
send_ldap_result( op, rs );
return rs->sr_err;
#ifdef SLAP_ZONE_ALLOC
slap_zn_runlock(bdb->bi_cache.c_zctx, e);
#endif
- bdb_cache_return_entry_r( bdb->bi_dbenv, &bdb->bi_cache, e, &lock );
+ bdb_cache_return_entry_r( bdb, e, &lock );
e = NULL;
if ( erefs ) {
slap_zn_runlock(bdb->bi_cache.c_zctx, e);
#endif
if ( e != &e_root ) {
- bdb_cache_return_entry_r(bdb->bi_dbenv, &bdb->bi_cache, e, &lock);
+ bdb_cache_return_entry_r(bdb, e, &lock);
}
send_ldap_result( op, rs );
return 1;
slap_zn_runlock(bdb->bi_cache.c_zctx, e);
#endif
if ( e != &e_root ) {
- bdb_cache_return_entry_r(bdb->bi_dbenv, &bdb->bi_cache, e, &lock);
+ bdb_cache_return_entry_r(bdb, e, &lock);
}
e = NULL;
#ifdef SLAP_ZONE_ALLOC
slap_zn_runlock(bdb->bi_cache.c_zctx, e);
#endif
- bdb_cache_return_entry_r( bdb->bi_dbenv,
- &bdb->bi_cache, e, &lock );
+ bdb_cache_return_entry_r( bdb, e, &lock );
e = NULL;
send_paged_response( op, rs, &lastid, tentries );
goto done;
#ifdef SLAP_ZONE_ALLOC
slap_zn_runlock(bdb->bi_cache.c_zctx, e);
#endif
- bdb_cache_return_entry_r(bdb->bi_dbenv,
- &bdb->bi_cache, e, &lock);
+ bdb_cache_return_entry_r(bdb, e, &lock);
e = NULL;
rs->sr_entry = NULL;
if ( rs->sr_err == LDAP_SIZELIMIT_EXCEEDED ) {
#ifdef SLAP_ZONE_ALLOC
slap_zn_runlock(bdb->bi_cache.c_zctx, e);
#endif
- bdb_cache_return_entry_r( bdb->bi_dbenv,
- &bdb->bi_cache, e , &lock );
+ bdb_cache_return_entry_r( bdb, e , &lock );
e = NULL;
rs->sr_entry = NULL;
}