size_t textlen = sizeof textbuf;
AttributeDescription *children = slap_schema.si_ad_children;
AttributeDescription *entry = slap_schema.si_ad_entry;
- DB_TXN *ltid = NULL, *lt2;
+ DB_TXN *ltid = NULL, *lt2, *rtxn;
ID eid = NOID;
struct bdb_op_info opinfo = {0};
int subentry;
- BDB_LOCKER locker = 0, rlocker = 0;
DB_LOCK lock;
int num_retries = 0;
subentry = is_entry_subentry( op->oq_add.rs_e );
- /* Get our thread locker ID */
- rs->sr_err = LOCK_ID( bdb->bi_dbenv, &rlocker );
+ /* Get our reader TXN */
+ rs->sr_err = bdb_reader_get( op, bdb->bi_dbenv, &rtxn );
if( 0 ) {
retry: /* transaction retry */
goto return_results;
}
- locker = TXN_ID ( ltid );
-
opinfo.boi_oe.oe_key = bdb;
opinfo.boi_txn = ltid;
opinfo.boi_err = 0;
/* get entry or parent */
rs->sr_err = bdb_dn2entry( op, ltid, &op->ora_e->e_nname, &ei,
- 1, locker, &lock );
+ 1, &lock );
switch( rs->sr_err ) {
case 0:
rs->sr_err = LDAP_ALREADY_EXISTS;
nrdn = op->ora_e->e_nname;
}
- /* Use the thread locker here, outside the txn */
- bdb_cache_add( bdb, ei, op->ora_e, &nrdn, rlocker, &lock );
+ /* Use the reader txn here, outside the add txn */
+ bdb_cache_add( bdb, ei, op->ora_e, &nrdn, rtxn, &lock );
if(( rs->sr_err=TXN_COMMIT( ltid, 0 )) != 0 ) {
rs->sr_text = "txn_commit failed";
#define BDB_PAGESIZE 4096 /* BDB's original default */
#endif
-/* 4.6.18 redefines cursor->locker */
-#if DB_VERSION_FULL >= 0x04060012
-
-struct __db_locker {
- u_int32_t id;
-};
-
-typedef struct __db_locker * BDB_LOCKER;
-
-extern int __lock_getlocker(DB_LOCKTAB *lt, u_int32_t locker, int create, DB_LOCKER **ret);
-
-#define CURSOR_SETLOCKER(cursor, id) cursor->locker = id
-#define CURSOR_GETLOCKER(cursor) cursor->locker
-#define BDB_LOCKID(locker) locker->id
-#else
-
-typedef u_int32_t BDB_LOCKER;
-
-#define CURSOR_SETLOCKER(cursor, id) cursor->locker = id
-#define CURSOR_GETLOCKER(cursor) cursor->locker
-#define BDB_LOCKID(locker) locker
-
-#endif
-
#define DEFAULT_CACHE_SIZE 1000
/* The default search IDL stack cache depth */
int c_eiused; /* EntryInfo's in use */
int c_leaves; /* EntryInfo leaf nodes */
int c_purging;
- BDB_LOCKER c_locker; /* used by lru cleaner */
+ DB_TXN *c_txn; /* used by lru cleaner */
ldap_pvt_thread_rdwr_t c_rwlock;
ldap_pvt_thread_mutex_t c_lru_mutex;
ldap_pvt_thread_mutex_t c_count_mutex;
((db)->open)(db, NULL, file, name, type, flags, mode)
#endif
-/* BDB 4.6.18 makes locker a struct instead of an int */
-#if DB_VERSION_FULL >= 0x04060012
-#undef TXN_ID
-#define TXN_ID(txn) (txn)->locker
-#endif
-
/* #undef BDB_LOG_DEBUG */
#ifdef BDB_LOG_DEBUG
#define DB_BUFFER_SMALL ENOMEM
#endif
-#define BDB_REUSE_LOCKERS
-
#define BDB_CSN_COMMIT 0
#define BDB_CSN_ABORT 1
#define BDB_CSN_RETRY 2
AttributeDescription *password = slap_schema.si_ad_userPassword;
- BDB_LOCKER locker;
+ DB_TXN *rtxn;
DB_LOCK lock;
Debug( LDAP_DEBUG_ARGS,
break;
}
- rs->sr_err = LOCK_ID(bdb->bi_dbenv, &locker);
+ rs->sr_err = bdb_reader_get(op, bdb->bi_dbenv, &rtxn);
switch(rs->sr_err) {
case 0:
break;
dn2entry_retry:
/* get entry with reader lock */
- rs->sr_err = bdb_dn2entry( op, NULL, &op->o_req_ndn, &ei, 1,
- locker, &lock );
+ rs->sr_err = bdb_dn2entry( op, rtxn, &op->o_req_ndn, &ei, 1,
+ &lock );
switch(rs->sr_err) {
case DB_NOTFOUND:
break;
case LDAP_BUSY:
send_ldap_error( op, rs, LDAP_BUSY, "ldap_server_busy" );
- LOCK_ID_FREE(bdb->bi_dbenv, locker);
return LDAP_BUSY;
case DB_LOCK_DEADLOCK:
case DB_LOCK_NOTGRANTED:
goto dn2entry_retry;
default:
send_ldap_error( op, rs, LDAP_OTHER, "internal error" );
- LOCK_ID_FREE(bdb->bi_dbenv, locker);
return rs->sr_err;
}
rs->sr_err = LDAP_INVALID_CREDENTIALS;
send_ldap_result( op, rs );
- LOCK_ID_FREE(bdb->bi_dbenv, locker);
-
return rs->sr_err;
}
bdb_cache_return_entry_r( bdb, e, &lock );
}
- LOCK_ID_FREE(bdb->bi_dbenv, locker);
-
if ( rs->sr_err ) {
send_ldap_result( op, rs );
if ( rs->sr_ref ) {
int
bdb_cache_entry_db_relock(
struct bdb_info *bdb,
- BDB_LOCKER locker,
+ DB_TXN *txn,
EntryInfo *ei,
int rw,
int tryOnly,
list[1].lock = *lock;
list[1].mode = rw ? DB_LOCK_WRITE : DB_LOCK_READ;
list[1].obj = &lockobj;
- rc = bdb->bi_dbenv->lock_vec(bdb->bi_dbenv, BDB_LOCKID(locker), tryOnly ? DB_LOCK_NOWAIT : 0,
+ rc = bdb->bi_dbenv->lock_vec(bdb->bi_dbenv, TXN_ID(txn), tryOnly ? DB_LOCK_NOWAIT : 0,
list, 2, NULL );
if (rc && !tryOnly) {
}
static int
-bdb_cache_entry_db_lock( struct bdb_info *bdb, BDB_LOCKER locker, EntryInfo *ei,
+bdb_cache_entry_db_lock( struct bdb_info *bdb, DB_TXN *txn, 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(bdb->bi_dbenv, BDB_LOCKID(locker), tryOnly ? DB_LOCK_NOWAIT : 0,
+ rc = LOCK_GET(bdb->bi_dbenv, TXN_ID(txn), tryOnly ? DB_LOCK_NOWAIT : 0,
&lockobj, db_rw, lock);
if (rc && !tryOnly) {
Debug( LDAP_DEBUG_TRACE,
int
bdb_cache_find_ndn(
Operation *op,
- BDB_LOCKER locker,
+ DB_TXN *txn,
struct berval *ndn,
EntryInfo **res )
{
ei.bei_nrdn.bv_val );
lock.mode = DB_LOCK_NG;
- rc = bdb_dn2id( op, &ei.bei_nrdn, &ei, locker, &lock );
+ rc = bdb_dn2id( op, &ei.bei_nrdn, &ei, txn, &lock );
if (rc) {
bdb_cache_entryinfo_lock( eip );
bdb_cache_entry_db_unlock( bdb, &lock );
int
hdb_cache_find_parent(
Operation *op,
- BDB_LOCKER locker,
+ DB_TXN *txn,
ID id,
EntryInfo **res )
{
ei.bei_ckids = 0;
for (;;) {
- rc = hdb_dn2id_parent( op, locker, &ei, &eip.bei_id );
+ rc = hdb_dn2id_parent( op, txn, &ei, &eip.bei_id );
if ( rc ) break;
/* Save the previous node, if any */
return;
}
- if ( bdb->bi_cache.c_locker ) {
+ if ( bdb->bi_cache.c_txn ) {
lockp = &lock;
} else {
lockp = NULL;
* the object is idle.
*/
if ( bdb_cache_entry_db_lock( bdb,
- bdb->bi_cache.c_locker, elru, 1, 1, lockp ) == 0 ) {
+ bdb->bi_cache.c_txn, elru, 1, 1, lockp ) == 0 ) {
/* Free entry for this node if it's present */
if ( elru->bei_e ) {
ID id,
EntryInfo **eip,
int flag,
- BDB_LOCKER locker,
DB_LOCK *lock )
{
struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
/* See if the ID exists in the database; add it to the cache if so */
if ( !*eip ) {
#ifndef BDB_HIER
- rc = bdb_id2entry( op->o_bd, tid, locker, id, &ep );
+ rc = bdb_id2entry( op->o_bd, tid, id, &ep );
if ( rc == 0 ) {
- rc = bdb_cache_find_ndn( op, locker,
+ rc = bdb_cache_find_ndn( op, tid,
&ep->e_nname, eip );
if ( *eip ) flag |= ID_LOCKED;
if ( rc ) {
}
}
#else
- rc = hdb_cache_find_parent(op, locker, id, eip );
+ rc = hdb_cache_find_parent(op, tid, id, eip );
if ( rc == 0 ) flag |= ID_LOCKED;
#endif
}
bdb_cache_entryinfo_unlock( *eip );
flag ^= ID_LOCKED;
}
- rc = bdb_cache_entry_db_lock( bdb, locker, *eip, load, 0, lock );
+ rc = bdb_cache_entry_db_lock( bdb, tid, *eip, load, 0, lock );
if ( (*eip)->bei_state & CACHE_ENTRY_DELETED ) {
rc = DB_NOTFOUND;
bdb_cache_entry_db_unlock( bdb, lock );
} else if ( rc == 0 ) {
if ( load ) {
if ( !ep) {
- rc = bdb_id2entry( op->o_bd, tid, locker, id, &ep );
+ rc = bdb_id2entry( op->o_bd, tid, id, &ep );
}
if ( rc == 0 ) {
ep->e_private = *eip;
}
if ( rc == 0 ) {
/* If we succeeded, downgrade back to a readlock. */
- rc = bdb_cache_entry_db_relock( bdb, locker,
+ rc = bdb_cache_entry_db_relock( bdb, tid,
*eip, 0, 0, lock );
} else {
/* Otherwise, release the lock. */
rc = bdb_fix_dn( (*eip)->bei_e, 1 );
if ( rc ) {
bdb_cache_entry_db_relock( bdb,
- locker, *eip, 1, 0, lock );
+ tid, *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,
- locker, *eip, 0, 0, lock );
+ tid, *eip, 0, 0, lock );
}
#endif
}
EntryInfo *eip,
Entry *e,
struct berval *nrdn,
- BDB_LOCKER locker,
+ DB_TXN *txn,
DB_LOCK *lock )
{
EntryInfo *new, ei;
/* 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, locker, &ei, 0, 0, lock );
+ rc = bdb_cache_entry_db_lock( bdb, txn, &ei, 0, 0, lock );
if ( rc ) {
bdb_cache_entryinfo_unlock( eip );
return rc;
struct bdb_info *bdb,
Entry *e,
Attribute *newAttrs,
- BDB_LOCKER locker,
+ DB_TXN *txn,
DB_LOCK *lock )
{
EntryInfo *ei = BEI(e);
int rc;
/* Get write lock on data */
- rc = bdb_cache_entry_db_relock( bdb, locker, ei, 1, 0, lock );
+ rc = bdb_cache_entry_db_relock( bdb, txn, 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.
struct berval *nrdn,
Entry *new,
EntryInfo *ein,
- BDB_LOCKER locker,
+ DB_TXN *txn,
DB_LOCK *lock )
{
EntryInfo *ei = BEI(e), *pei;
#endif
/* Get write lock on data */
- rc = bdb_cache_entry_db_relock( bdb, locker, ei, 1, 0, lock );
+ rc = bdb_cache_entry_db_relock( bdb, txn, ei, 1, 0, lock );
if ( rc ) return rc;
/* If we've done repeated mods on a cached entry, then e_attrs
bdb_cache_delete(
struct bdb_info *bdb,
Entry *e,
- BDB_LOCKER locker,
+ DB_TXN *txn,
DB_LOCK *lock )
{
EntryInfo *ei = BEI(e);
bdb_cache_entryinfo_unlock( ei );
/* Get write lock on the data */
- rc = bdb_cache_entry_db_relock( bdb, locker, ei, 1, 0, lock );
+ rc = bdb_cache_entry_db_relock( bdb, txn, ei, 1, 0, lock );
if ( rc ) {
/* couldn't lock, undo and give up */
ei->bei_state ^= CACHE_ENTRY_DELETED;
#endif
#endif
-#ifdef BDB_REUSE_LOCKERS
static void
-bdb_locker_id_free( void *key, void *data )
+bdb_reader_free( void *key, void *data )
{
- DB_ENV *env = key;
- u_int32_t lockid;
- int rc;
+ /* DB_ENV *env = key; */
+ DB_TXN *txn = data;
-#if DB_VERSION_FULL >= 0x04060012
- BDB_LOCKER lptr = data;
- lockid = lptr->id;
-#else
- lockid = (long)data;
-#endif
- rc = XLOCK_ID_FREE( env, lockid );
- if ( rc == EINVAL ) {
- DB_LOCKREQ lr;
- Debug( LDAP_DEBUG_ANY,
- "bdb_locker_id_free: %lu err %s(%d)\n",
- (unsigned long) lockid, db_strerror(rc), rc );
- /* release all locks held by this locker. */
- lr.op = DB_LOCK_PUT_ALL;
- lr.obj = NULL;
- env->lock_vec( env, lockid, 0, &lr, 1, NULL );
- XLOCK_ID_FREE( env, lockid );
- }
+ TXN_ABORT( txn );
}
/* free up any keys used by the main thread */
void
-bdb_locker_flush( DB_ENV *env )
+bdb_reader_flush( DB_ENV *env )
{
void *data;
void *ctx = ldap_pvt_thread_pool_context();
if ( !ldap_pvt_thread_pool_getkey( ctx, env, &data, NULL ) ) {
ldap_pvt_thread_pool_setkey( ctx, env, NULL, 0, NULL, NULL );
- bdb_locker_id_free( env, data );
+ bdb_reader_free( env, data );
}
}
int
-bdb_locker_id( Operation *op, DB_ENV *env, BDB_LOCKER *locker )
+bdb_reader_get( Operation *op, DB_ENV *env, DB_TXN **txn )
{
int i, rc;
- u_int32_t lockid;
void *data;
void *ctx;
- if ( !env || !locker ) return -1;
+ if ( !env || !txn ) return -1;
/* If no op was provided, try to find the ctx anyway... */
if ( op ) {
/* Shouldn't happen unless we're single-threaded */
if ( !ctx ) {
- *locker = 0;
+ *txn = NULL;
return 0;
}
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 );
+ rc = TXN_BEGIN( env, NULL, txn, DB_READ_COMMITTED | DB_TXN_NOWAIT );
if (rc) ldap_pvt_thread_yield();
}
if ( rc != 0) {
return rc;
}
-#if DB_VERSION_FULL >= 0x04060012
- { BDB_LOCKER lptr;
- __lock_getlocker( env->lk_handle, lockid, 0, &lptr );
- data = lptr;
- }
-#else
- data = (void *)((long)lockid);
-#endif
+ data = *txn;
if ( ( rc = ldap_pvt_thread_pool_setkey( ctx, env,
- data, bdb_locker_id_free, NULL, NULL ) ) ) {
- XLOCK_ID_FREE( env, lockid );
- Debug( LDAP_DEBUG_ANY, "bdb_locker_id: err %s(%d)\n",
+ data, bdb_reader_free, NULL, NULL ) ) ) {
+ TXN_ABORT( *txn );
+ Debug( LDAP_DEBUG_ANY, "bdb_reader_get: err %s(%d)\n",
db_strerror(rc), rc, 0 );
return rc;
}
} else {
- lockid = (long)data;
+ *txn = data;
}
-#if DB_VERSION_FULL >= 0x04060012
- *locker = data;
-#else
- *locker = lockid;
-#endif
return 0;
}
-#endif /* BDB_REUSE_LOCKERS */
Attribute *a;
int manageDSAit = get_manageDSAit( op );
- BDB_LOCKER locker;
+ DB_TXN *rtxn;
DB_LOCK lock;
- rs->sr_err = LOCK_ID(bdb->bi_dbenv, &locker);
+ rs->sr_err = bdb_reader_get(op, bdb->bi_dbenv, &rtxn);
switch(rs->sr_err) {
case 0:
break;
dn2entry_retry:
/* get entry */
- rs->sr_err = bdb_dn2entry( op, NULL, &op->o_req_ndn, &ei, 1,
- locker, &lock );
+ rs->sr_err = bdb_dn2entry( op, rtxn, &op->o_req_ndn, &ei, 1,
+ &lock );
switch( rs->sr_err ) {
case DB_NOTFOUND:
bdb_cache_return_entry_r( bdb, e, &lock );
}
- LOCK_ID_FREE ( bdb->bi_dbenv, locker );
return rs->sr_err;
}
DBT key, data;
DB_TXN *txn;
DB_LOCK lock;
- BDB_LOCKER locker;
ID id, nid;
EntryInfo *ei;
int rc, getnext = 1;
rc = TXN_BEGIN( bdb->bi_dbenv, NULL, &txn, bdb->bi_db_opflags );
if ( rc )
break;
- locker = TXN_ID( txn );
if ( getnext ) {
getnext = 0;
BDB_ID2DISK( id, &nid );
}
ei = NULL;
- rc = bdb_cache_find_id( op, txn, id, &ei, 0, locker, &lock );
+ rc = bdb_cache_find_id( op, txn, id, &ei, 0, &lock );
if ( rc ) {
TXN_ABORT( txn );
if ( rc == DB_LOCK_DEADLOCK ) {
struct bdb_op_info opinfo = {0};
ID eid;
- BDB_LOCKER locker = 0;
DB_LOCK lock, plock;
int num_retries = 0;
goto return_results;
}
- locker = TXN_ID ( ltid );
-
opinfo.boi_oe.oe_key = bdb;
opinfo.boi_txn = ltid;
opinfo.boi_err = 0;
/* get entry */
rs->sr_err = bdb_dn2entry( op, ltid, &op->o_req_ndn, &ei, 1,
- locker, &lock );
+ &lock );
switch( rs->sr_err ) {
case 0:
goto return_results;
}
- rc = bdb_cache_find_id( op, ltid, eip->bei_id, &eip, 0, locker, &plock );
+ rc = bdb_cache_find_id( op, ltid, eip->bei_id, &eip, 0, &plock );
switch( rc ) {
case DB_LOCK_DEADLOCK:
case DB_LOCK_NOTGRANTED:
BDB_LOG_PRINTF( bdb->bi_dbenv, ltid, "slapd Cache delete %s(%d)",
e->e_nname.bv_val, e->e_id );
- rc = bdb_cache_delete( bdb, e, locker, &lock );
+ rc = bdb_cache_delete( bdb, e, ltid, &lock );
switch( rc ) {
case DB_LOCK_DEADLOCK:
case DB_LOCK_NOTGRANTED:
struct berval *dn,
EntryInfo **e,
int matched,
- BDB_LOCKER locker,
DB_LOCK *lock )
{
EntryInfo *ei = NULL;
*e = NULL;
- rc = bdb_cache_find_ndn( op, locker, dn, &ei );
+ rc = bdb_cache_find_ndn( op, tid, dn, &ei );
if ( rc ) {
if ( matched && rc == DB_NOTFOUND ) {
/* Set the return value, whether we have its entry
*e = ei;
if ( ei && ei->bei_id ) {
rc2 = bdb_cache_find_id( op, tid, ei->bei_id,
- &ei, ID_LOCKED, locker, lock );
+ &ei, ID_LOCKED, lock );
if ( rc2 ) rc = rc2;
} else if ( ei ) {
bdb_cache_entryinfo_unlock( ei );
}
} else {
rc = bdb_cache_find_id( op, tid, ei->bei_id, &ei, ID_LOCKED,
- locker, lock );
+ lock );
if ( rc == 0 ) {
*e = ei;
} else if ( matched && rc == DB_NOTFOUND ) {
if ( ei->bei_parent ) {
ei = ei->bei_parent;
rc2 = bdb_cache_find_id( op, tid, ei->bei_id, &ei, 0,
- locker, lock );
+ lock );
if ( rc2 ) rc = rc2;
}
*e = ei;
static int
bdb_dn2id_lock( struct bdb_info *bdb, struct berval *dn,
- int rw, BDB_LOCKER locker, DB_LOCK *lock )
+ int rw, DB_TXN *txn, DB_LOCK *lock )
{
int rc;
DBT lockobj;
int db_rw;
- if (!locker)
+ if (!txn)
return 0;
if (rw)
lockobj.data = dn->bv_val;
lockobj.size = dn->bv_len;
- rc = LOCK_GET(bdb->bi_dbenv, BDB_LOCKID(locker), DB_LOCK_NOWAIT,
+ rc = LOCK_GET(bdb->bi_dbenv, TXN_ID(txn), DB_LOCK_NOWAIT,
&lockobj, db_rw, lock);
return rc;
}
ptr.bv_val[ptr.bv_len] = '\0';
/* We hold this lock until the TXN completes */
- rc = bdb_dn2id_lock( bdb, &e->e_nname, 1, TXN_ID( txn ), &lock );
+ rc = bdb_dn2id_lock( bdb, &e->e_nname, 1, txn, &lock );
if ( rc ) goto done;
/* delete it */
Operation *op,
struct berval *dn,
EntryInfo *ei,
- BDB_LOCKER locker,
+ DB_TXN *txn,
DB_LOCK *lock )
{
struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
data.ulen = sizeof(ID);
data.flags = DB_DBT_USERMEM;
- rc = db->cursor( db, NULL, &cursor, bdb->bi_db_opflags );
+ rc = db->cursor( db, txn, &cursor, bdb->bi_db_opflags );
if ( rc ) goto func_leave;
- rc = bdb_dn2id_lock( bdb, dn, 0, locker, lock );
+ rc = bdb_dn2id_lock( bdb, dn, 0, txn, lock );
if ( rc ) goto nolock;
- if ( locker ) {
- CURSOR_SETLOCKER(cursor, locker);
- }
-
/* fetch it */
rc = cursor->c_get( cursor, &key, &data, DB_SET );
int
bdb_dn2idl(
Operation *op,
- BDB_LOCKER locker,
+ DB_TXN *txn,
struct berval *ndn,
EntryInfo *ei,
ID *ids,
AC_MEMCPY( &((char *)key.data)[1], ndn->bv_val, key.size - 1 );
BDB_IDL_ZERO( ids );
- rc = bdb_idl_fetch_key( op->o_bd, db, locker, &key, ids, NULL, 0 );
+ rc = bdb_idl_fetch_key( op->o_bd, db, txn, &key, ids, NULL, 0 );
if( rc != 0 ) {
Debug( LDAP_DEBUG_TRACE,
if ( rc ) goto func_leave;
/* We hold this lock until the TXN completes */
- rc = bdb_dn2id_lock( bdb, &e->e_nname, 1, TXN_ID( txn ), &lock );
+ rc = bdb_dn2id_lock( bdb, &e->e_nname, 1, txn, &lock );
if ( rc ) goto nolock;
/* Delete our ID from the parent's list */
Operation *op,
struct berval *in,
EntryInfo *ei,
- BDB_LOCKER locker,
+ DB_TXN *txn,
DB_LOCK *lock )
{
struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
data.dlen = data.ulen;
data.flags = DB_DBT_USERMEM | DB_DBT_PARTIAL;
- rc = db->cursor( db, NULL, &cursor, bdb->bi_db_opflags );
+ rc = db->cursor( db, txn, &cursor, bdb->bi_db_opflags );
if ( rc ) return rc;
- if ( locker ) {
- CURSOR_SETLOCKER( cursor, locker );
- }
d = op->o_tmpalloc( data.size * 3, op->o_tmpmemctx );
d->nrdnlen[1] = nrlen & 0xff;
*ptr = '\0';
data.data = d;
- rc = bdb_dn2id_lock( bdb, in, 0, locker, lock );
+ rc = bdb_dn2id_lock( bdb, in, 0, txn, lock );
if ( rc ) goto func_leave;
rc = cursor->c_get( cursor, &key, &data, DB_GET_BOTH_RANGE );
int
hdb_dn2id_parent(
Operation *op,
- BDB_LOCKER locker,
+ DB_TXN *txn,
EntryInfo *ei,
ID *idp )
{
DBTzero(&data);
data.flags = DB_DBT_USERMEM;
- rc = db->cursor( db, NULL, &cursor, bdb->bi_db_opflags );
+ rc = db->cursor( db, txn, &cursor, bdb->bi_db_opflags );
if ( rc ) return rc;
- if ( locker ) {
- CURSOR_SETLOCKER(cursor, locker);
- }
data.ulen = sizeof(diskNode) + (SLAP_LDAPDN_MAXLEN * 2);
d = op->o_tmpalloc( data.ulen, op->o_tmpmemctx );
struct dn2id_cookie {
struct bdb_info *bdb;
Operation *op;
- BDB_LOCKER locker;
+ DB_TXN *txn;
EntryInfo *ei;
ID *ids;
ID *tmp;
int
hdb_dn2idl(
Operation *op,
- BDB_LOCKER locker,
+ DB_TXN *txn,
struct berval *ndn,
EntryInfo *ei,
ID *ids,
cx.tmp = stack;
cx.buf = stack + BDB_IDL_UM_SIZE;
cx.op = op;
- cx.locker = locker;
+ cx.txn = txn;
cx.need_sort = 0;
cx.depth = 0;
static int presence_candidates(
Operation *op,
- BDB_LOCKER locker,
+ DB_TXN *rtxn,
AttributeDescription *desc,
ID *ids );
static int equality_candidates(
Operation *op,
- BDB_LOCKER locker,
+ DB_TXN *rtxn,
AttributeAssertion *ava,
ID *ids,
ID *tmp );
static int inequality_candidates(
Operation *op,
- BDB_LOCKER locker,
+ DB_TXN *rtxn,
AttributeAssertion *ava,
ID *ids,
ID *tmp,
int gtorlt );
static int approx_candidates(
Operation *op,
- BDB_LOCKER locker,
+ DB_TXN *rtxn,
AttributeAssertion *ava,
ID *ids,
ID *tmp );
static int substring_candidates(
Operation *op,
- BDB_LOCKER locker,
+ DB_TXN *rtxn,
SubstringsAssertion *sub,
ID *ids,
ID *tmp );
static int list_candidates(
Operation *op,
- BDB_LOCKER locker,
+ DB_TXN *rtxn,
Filter *flist,
int ftype,
ID *ids,
static int
ext_candidates(
Operation *op,
- BDB_LOCKER locker,
+ DB_TXN *rtxn,
MatchingRuleAssertion *mra,
ID *ids,
ID *tmp,
static int
comp_candidates (
Operation *op,
- BDB_LOCKER locker,
+ DB_TXN *rtxn,
MatchingRuleAssertion *mra,
ComponentFilter *f,
ID *ids,
static int
ava_comp_candidates (
Operation *op,
- BDB_LOCKER locker,
+ DB_TXN *rtxn,
AttributeAssertion *ava,
AttributeAliasing *aa,
ID *ids,
int
bdb_filter_candidates(
Operation *op,
- BDB_LOCKER locker,
+ DB_TXN *rtxn,
Filter *f,
ID *ids,
ID *tmp,
break;
case LDAP_FILTER_PRESENT:
Debug( LDAP_DEBUG_FILTER, "\tPRESENT\n", 0, 0, 0 );
- rc = presence_candidates( op, locker, f->f_desc, ids );
+ rc = presence_candidates( op, rtxn, f->f_desc, ids );
break;
case LDAP_FILTER_EQUALITY:
Debug( LDAP_DEBUG_FILTER, "\tEQUALITY\n", 0, 0, 0 );
#ifdef LDAP_COMP_MATCH
if ( is_aliased_attribute && ( aa = is_aliased_attribute ( f->f_ava->aa_desc ) ) ) {
- rc = ava_comp_candidates ( op, locker, f->f_ava, aa, ids, tmp, stack );
+ rc = ava_comp_candidates ( op, rtxn, f->f_ava, aa, ids, tmp, stack );
}
else
#endif
{
- rc = equality_candidates( op, locker, f->f_ava, ids, tmp );
+ rc = equality_candidates( op, rtxn, f->f_ava, ids, tmp );
}
break;
case LDAP_FILTER_APPROX:
Debug( LDAP_DEBUG_FILTER, "\tAPPROX\n", 0, 0, 0 );
- rc = approx_candidates( op, locker, f->f_ava, ids, tmp );
+ rc = approx_candidates( op, rtxn, f->f_ava, ids, tmp );
break;
case LDAP_FILTER_SUBSTRINGS:
Debug( LDAP_DEBUG_FILTER, "\tSUBSTRINGS\n", 0, 0, 0 );
- rc = substring_candidates( op, locker, f->f_sub, ids, tmp );
+ rc = substring_candidates( op, rtxn, f->f_sub, ids, tmp );
break;
case LDAP_FILTER_GE:
Debug( LDAP_DEBUG_FILTER, "\tGE\n", 0, 0, 0 );
if( f->f_ava->aa_desc->ad_type->sat_ordering &&
( f->f_ava->aa_desc->ad_type->sat_ordering->smr_usage & SLAP_MR_ORDERED_INDEX ) )
- rc = inequality_candidates( op, locker, f->f_ava, ids, tmp, LDAP_FILTER_GE );
+ rc = inequality_candidates( op, rtxn, f->f_ava, ids, tmp, LDAP_FILTER_GE );
else
- rc = presence_candidates( op, locker, f->f_ava->aa_desc, ids );
+ rc = presence_candidates( op, rtxn, f->f_ava->aa_desc, ids );
break;
case LDAP_FILTER_LE:
Debug( LDAP_DEBUG_FILTER, "\tLE\n", 0, 0, 0 );
if( f->f_ava->aa_desc->ad_type->sat_ordering &&
( f->f_ava->aa_desc->ad_type->sat_ordering->smr_usage & SLAP_MR_ORDERED_INDEX ) )
- rc = inequality_candidates( op, locker, f->f_ava, ids, tmp, LDAP_FILTER_LE );
+ rc = inequality_candidates( op, rtxn, f->f_ava, ids, tmp, LDAP_FILTER_LE );
else
- rc = presence_candidates( op, locker, f->f_ava->aa_desc, ids );
+ rc = presence_candidates( op, rtxn, f->f_ava->aa_desc, ids );
break;
case LDAP_FILTER_NOT:
case LDAP_FILTER_AND:
Debug( LDAP_DEBUG_FILTER, "\tAND\n", 0, 0, 0 );
- rc = list_candidates( op, locker,
+ rc = list_candidates( op, rtxn,
f->f_and, LDAP_FILTER_AND, ids, tmp, stack );
break;
case LDAP_FILTER_OR:
Debug( LDAP_DEBUG_FILTER, "\tOR\n", 0, 0, 0 );
- rc = list_candidates( op, locker,
+ rc = list_candidates( op, rtxn,
f->f_or, LDAP_FILTER_OR, ids, tmp, stack );
break;
case LDAP_FILTER_EXT:
Debug( LDAP_DEBUG_FILTER, "\tEXT\n", 0, 0, 0 );
- rc = ext_candidates( op, locker, f->f_mra, ids, tmp, stack );
+ rc = ext_candidates( op, rtxn, f->f_mra, ids, tmp, stack );
break;
default:
Debug( LDAP_DEBUG_FILTER, "\tUNKNOWN %lu\n",
static int
comp_list_candidates(
Operation *op,
- BDB_LOCKER locker,
+ DB_TXN *rtxn,
MatchingRuleAssertion* mra,
ComponentFilter *flist,
int ftype,
continue;
}
BDB_IDL_ZERO( save );
- rc = comp_candidates( op, locker, mra, f, save, tmp, save+BDB_IDL_UM_SIZE );
+ rc = comp_candidates( op, rtxn, mra, f, save, tmp, save+BDB_IDL_UM_SIZE );
if ( rc != 0 ) {
if ( ftype == LDAP_COMP_FILTER_AND ) {
static int
comp_equality_candidates (
Operation *op,
- BDB_LOCKER locker,
+ DB_TXN *rtxn,
MatchingRuleAssertion *mra,
ComponentAssertion *ca,
ID *ids,
return 0;
}
for ( i= 0; keys[i].bv_val != NULL; i++ ) {
- rc = bdb_key_read( op->o_bd, db, locker, &keys[i], tmp, NULL, 0 );
+ rc = bdb_key_read( op->o_bd, db, rtxn, &keys[i], tmp, NULL, 0 );
if( rc == DB_NOTFOUND ) {
BDB_IDL_ZERO( ids );
static int
ava_comp_candidates (
Operation *op,
- BDB_LOCKER locker,
+ DB_TXN *rtxn,
AttributeAssertion *ava,
AttributeAliasing *aa,
ID *ids,
mra.ma_desc = aa->aa_aliased_ad;
mra.ma_rule = ava->aa_desc->ad_type->sat_equality;
- return comp_candidates ( op, locker, &mra, ava->aa_cf, ids, tmp, stack );
+ return comp_candidates ( op, rtxn, &mra, ava->aa_cf, ids, tmp, stack );
}
static int
comp_candidates (
Operation *op,
- BDB_LOCKER locker,
+ DB_TXN *rtxn,
MatchingRuleAssertion *mra,
ComponentFilter *f,
ID *ids,
rc = f->cf_result;
break;
case LDAP_COMP_FILTER_AND:
- rc = comp_list_candidates( op, locker, mra, f->cf_and, LDAP_COMP_FILTER_AND, ids, tmp, stack );
+ rc = comp_list_candidates( op, rtxn, mra, f->cf_and, LDAP_COMP_FILTER_AND, ids, tmp, stack );
break;
case LDAP_COMP_FILTER_OR:
- rc = comp_list_candidates( op, locker, mra, f->cf_or, LDAP_COMP_FILTER_OR, ids, tmp, stack );
+ rc = comp_list_candidates( op, rtxn, mra, f->cf_or, LDAP_COMP_FILTER_OR, ids, tmp, stack );
break;
case LDAP_COMP_FILTER_NOT:
/* No component indexing supported for NOT filter */
rc = LDAP_PROTOCOL_ERROR;
break;
case LDAP_COMP_FILTER_ITEM:
- rc = comp_equality_candidates( op, locker, mra, f->cf_ca, ids, tmp, stack );
+ rc = comp_equality_candidates( op, rtxn, mra, f->cf_ca, ids, tmp, stack );
break;
default:
{
static int
ext_candidates(
Operation *op,
- BDB_LOCKER locker,
+ DB_TXN *rtxn,
MatchingRuleAssertion *mra,
ID *ids,
ID *tmp,
* Indexing for an extensible filter is not supported yet
*/
if ( mra->ma_cf ) {
- return comp_candidates ( op, locker, mra, mra->ma_cf, ids, tmp, stack);
+ return comp_candidates ( op, rtxn, mra, mra->ma_cf, ids, tmp, stack);
}
#endif
if ( mra->ma_desc == slap_schema.si_ad_entryDN ) {
BDB_IDL_ZERO( ids );
if ( mra->ma_rule == slap_schema.si_mr_distinguishedNameMatch ) {
ei = NULL;
- rc = bdb_cache_find_ndn( op, locker, &mra->ma_value, &ei );
+ rc = bdb_cache_find_ndn( op, rtxn, &mra->ma_value, &ei );
if ( rc == LDAP_SUCCESS )
bdb_idl_insert( ids, ei->bei_id );
if ( ei )
struct berval pdn;
ei = NULL;
dnParent( &mra->ma_value, &pdn );
- bdb_cache_find_ndn( op, locker, &pdn, &ei );
+ bdb_cache_find_ndn( op, rtxn, &pdn, &ei );
if ( ei ) {
bdb_cache_entryinfo_unlock( ei );
while ( ei && ei->bei_id ) {
scope = LDAP_SCOPE_BASE;
if ( scope > LDAP_SCOPE_BASE ) {
ei = NULL;
- rc = bdb_cache_find_ndn( op, locker, &mra->ma_value, &ei );
+ rc = bdb_cache_find_ndn( op, rtxn, &mra->ma_value, &ei );
if ( ei )
bdb_cache_entryinfo_unlock( ei );
if ( rc == LDAP_SUCCESS ) {
int sc = op->ors_scope;
op->ors_scope = scope;
- rc = bdb_dn2idl( op, locker, &mra->ma_value, ei, ids,
+ rc = bdb_dn2idl( op, rtxn, &mra->ma_value, ei, ids,
stack );
op->ors_scope = sc;
}
static int
list_candidates(
Operation *op,
- BDB_LOCKER locker,
+ DB_TXN *rtxn,
Filter *flist,
int ftype,
ID *ids,
continue;
}
BDB_IDL_ZERO( save );
- rc = bdb_filter_candidates( op, locker, f, save, tmp,
+ rc = bdb_filter_candidates( op, rtxn, f, save, tmp,
save+BDB_IDL_UM_SIZE );
if ( rc != 0 ) {
static int
presence_candidates(
Operation *op,
- BDB_LOCKER locker,
+ DB_TXN *rtxn,
AttributeDescription *desc,
ID *ids )
{
return -1;
}
- rc = bdb_key_read( op->o_bd, db, locker, &prefix, ids, NULL, 0 );
+ rc = bdb_key_read( op->o_bd, db, rtxn, &prefix, ids, NULL, 0 );
if( rc == DB_NOTFOUND ) {
BDB_IDL_ZERO( ids );
static int
equality_candidates(
Operation *op,
- BDB_LOCKER locker,
+ DB_TXN *rtxn,
AttributeAssertion *ava,
ID *ids,
ID *tmp )
}
for ( i= 0; keys[i].bv_val != NULL; i++ ) {
- rc = bdb_key_read( op->o_bd, db, locker, &keys[i], tmp, NULL, 0 );
+ rc = bdb_key_read( op->o_bd, db, rtxn, &keys[i], tmp, NULL, 0 );
if( rc == DB_NOTFOUND ) {
BDB_IDL_ZERO( ids );
static int
approx_candidates(
Operation *op,
- BDB_LOCKER locker,
+ DB_TXN *rtxn,
AttributeAssertion *ava,
ID *ids,
ID *tmp )
}
for ( i= 0; keys[i].bv_val != NULL; i++ ) {
- rc = bdb_key_read( op->o_bd, db, locker, &keys[i], tmp, NULL, 0 );
+ rc = bdb_key_read( op->o_bd, db, rtxn, &keys[i], tmp, NULL, 0 );
if( rc == DB_NOTFOUND ) {
BDB_IDL_ZERO( ids );
static int
substring_candidates(
Operation *op,
- BDB_LOCKER locker,
+ DB_TXN *rtxn,
SubstringsAssertion *sub,
ID *ids,
ID *tmp )
}
for ( i= 0; keys[i].bv_val != NULL; i++ ) {
- rc = bdb_key_read( op->o_bd, db, locker, &keys[i], tmp, NULL, 0 );
+ rc = bdb_key_read( op->o_bd, db, rtxn, &keys[i], tmp, NULL, 0 );
if( rc == DB_NOTFOUND ) {
BDB_IDL_ZERO( ids );
static int
inequality_candidates(
Operation *op,
- BDB_LOCKER locker,
+ DB_TXN *rtxn,
AttributeAssertion *ava,
ID *ids,
ID *tmp,
BDB_IDL_ZERO( ids );
while(1) {
- rc = bdb_key_read( op->o_bd, db, locker, &keys[0], tmp, &cursor, gtorlt );
+ rc = bdb_key_read( op->o_bd, db, rtxn, &keys[0], tmp, &cursor, gtorlt );
if( rc == DB_NOTFOUND ) {
rc = 0;
int bdb_id2entry(
BackendDB *be,
DB_TXN *tid,
- BDB_LOCKER locker,
ID id,
Entry **e )
{
rc = db->cursor( db, tid, &cursor, bdb->bi_db_opflags );
if ( rc ) return rc;
- /* Use our own locker if needed */
- if ( !tid && locker ) {
- CURSOR_SETLOCKER( cursor, locker );
- }
-
/* Get the nattrs / nvals counts first */
data.ulen = data.dlen = sizeof(buf);
data.data = buf;
int rc;
const char *at_name = at ? at->ad_cname.bv_val : "(null)";
- BDB_LOCKER locker = 0;
DB_LOCK lock;
- int free_lock_id = 0;
Debug( LDAP_DEBUG_ARGS,
"=> bdb_entry_get: ndn: \"%s\"\n", ndn->bv_val, 0, 0 );
txn = boi->boi_txn;
}
- if ( txn != NULL ) {
- locker = TXN_ID ( txn );
- } else {
- rc = LOCK_ID ( bdb->bi_dbenv, &locker );
- free_lock_id = 1;
+ if ( !txn ) {
+ rc = bdb_reader_get( op, bdb->bi_dbenv, &txn );
switch(rc) {
case 0:
break;
dn2entry_retry:
/* can we find entry */
- rc = bdb_dn2entry( op, txn, ndn, &ei, 0, locker, &lock );
+ rc = bdb_dn2entry( op, txn, ndn, &ei, 0, &lock );
switch( rc ) {
case DB_NOTFOUND:
case 0:
goto dn2entry_retry;
default:
if ( boi ) boi->boi_err = rc;
- if ( free_lock_id ) {
- LOCK_ID_FREE( bdb->bi_dbenv, locker );
- }
return (rc != LDAP_BUSY) ? LDAP_OTHER : LDAP_BUSY;
}
if (ei) e = ei->bei_e;
Debug( LDAP_DEBUG_ACL,
"=> bdb_entry_get: cannot find entry: \"%s\"\n",
ndn->bv_val, 0, 0 );
- if ( free_lock_id ) {
- LOCK_ID_FREE( bdb->bi_dbenv, locker );
- }
return LDAP_NO_SUCH_OBJECT;
}
}
}
- if ( free_lock_id ) {
- LOCK_ID_FREE( bdb->bi_dbenv, locker );
- }
-
Debug( LDAP_DEBUG_TRACE,
"bdb_entry_get: rc=%d\n",
rc, 0, 0 );
bdb_idl_fetch_key(
BackendDB *be,
DB *db,
- BDB_LOCKER locker,
+ DB_TXN *txn,
DBT *key,
ID *ids,
DBC **saved_cursor,
/* If we're not reusing an existing cursor, get a new one */
if( opflag != DB_NEXT ) {
- rc = db->cursor( db, NULL, &cursor, bdb->bi_db_opflags );
+ rc = db->cursor( db, txn, &cursor, bdb->bi_db_opflags );
if( rc != 0 ) {
Debug( LDAP_DEBUG_ANY, "=> bdb_idl_fetch_key: "
"cursor failed: %s (%d)\n", db_strerror(rc), rc, 0 );
return rc;
}
- CURSOR_SETLOCKER( cursor, locker );
} else {
cursor = *saved_cursor;
}
/* DBEnv parameters */
bdb->bi_dbenv_home = ch_strdup( SLAPD_DEFAULT_DB_DIR );
- bdb->bi_dbenv_xflags = 0;
+ bdb->bi_dbenv_xflags = DB_TIME_NOTGRANTED;
bdb->bi_dbenv_mode = SLAPD_DEFAULT_DB_MODE;
bdb->bi_cache.c_maxsize = DEFAULT_CACHE_SIZE;
}
if ( !quick ) {
-#if DB_VERSION_FULL >= 0x04060012
- u_int32_t lid;
- XLOCK_ID(bdb->bi_dbenv, &lid);
- __lock_getlocker(bdb->bi_dbenv->lk_handle, lid, 0, &bdb->bi_cache.c_locker);
-#else
- XLOCK_ID(bdb->bi_dbenv, &bdb->bi_cache.c_locker);
-#endif
+ TXN_BEGIN(bdb->bi_dbenv, NULL, &bdb->bi_cache.c_txn, DB_READ_COMMITTED | DB_TXN_NOWAIT);
}
entry_prealloc( bdb->bi_cache.c_maxsize );
/* setup for empty-DN contexts */
if ( BER_BVISEMPTY( &be->be_nsuffix[0] )) {
- rc = bdb_id2entry( be, NULL, 0, 0, &e );
+ rc = bdb_id2entry( be, NULL, 0, &e );
}
if ( !e ) {
e = entry_alloc();
/* close db environment */
if( bdb->bi_dbenv ) {
/* Free cache locker if we enabled locking */
- if ( !( slapMode & SLAP_TOOL_QUICK ) && bdb->bi_cache.c_locker ) {
-#if DB_VERSION_FULL >= 0x04060012
- XLOCK_ID_FREE(bdb->bi_dbenv, bdb->bi_cache.c_locker->id);
-#else
- XLOCK_ID_FREE(bdb->bi_dbenv, bdb->bi_cache.c_locker);
-#endif
- bdb->bi_cache.c_locker = 0;
+ if ( !( slapMode & SLAP_TOOL_QUICK ) && bdb->bi_cache.c_txn ) {
+ TXN_ABORT( bdb->bi_cache.c_txn );
+ bdb->bi_cache.c_txn = NULL;
}
-#ifdef BDB_REUSE_LOCKERS
- bdb_locker_flush( bdb->bi_dbenv );
-#endif
+ bdb_reader_flush( bdb->bi_dbenv );
+
/* force a checkpoint, but not if we were ReadOnly,
* and not in Quick mode since there are no transactions there.
*/
db_env_set_func_free( ber_memfree );
db_env_set_func_malloc( (db_malloc *)ber_memalloc );
db_env_set_func_realloc( (db_realloc *)ber_memrealloc );
-#ifndef NO_THREAD
+#if !defined(NO_THREAD) && DB_VERSION_FULL <= 0x04070000
/* This is a no-op on a NO_THREAD build. Leave the default
* alone so that BDB will sleep on interprocess conflicts.
+ * Don't bother on BDB 4.7...
*/
db_env_set_func_yield( ldap_pvt_thread_yield );
#endif
bdb_key_read(
Backend *be,
DB *db,
- BDB_LOCKER locker,
+ DB_TXN *txn,
struct berval *k,
ID *ids,
DBC **saved_cursor,
key.ulen = key.size;
key.flags = DB_DBT_USERMEM;
- rc = bdb_idl_fetch_key( be, db, locker, &key, ids, saved_cursor, get_flag );
+ rc = bdb_idl_fetch_key( be, db, txn, &key, ids, saved_cursor, get_flag );
if( rc != LDAP_SUCCESS ) {
Debug( LDAP_DEBUG_TRACE, "<= bdb_index_read: failed (%d)\n",
Entry dummy = {0};
int fakeroot = 0;
- BDB_LOCKER locker = 0;
DB_LOCK lock;
int num_retries = 0;
goto return_results;
}
- locker = TXN_ID ( ltid );
-
opinfo.boi_oe.oe_key = bdb;
opinfo.boi_txn = ltid;
opinfo.boi_err = 0;
/* get entry or ancestor */
rs->sr_err = bdb_dn2entry( op, ltid, &op->o_req_ndn, &ei, 1,
- locker, &lock );
+ &lock );
if ( rs->sr_err != 0 ) {
Debug( LDAP_DEBUG_TRACE,
attrs_free( dummy.e_attrs );
} else {
- rc = bdb_cache_modify( bdb, e, dummy.e_attrs, locker, &lock );
+ rc = bdb_cache_modify( bdb, e, dummy.e_attrs, ltid, &lock );
switch( rc ) {
case DB_LOCK_DEADLOCK:
case DB_LOCK_NOTGRANTED:
int manageDSAit = get_manageDSAit( op );
- BDB_LOCKER locker = 0;
DB_LOCK lock, plock, nplock;
int num_retries = 0;
goto return_results;
}
- locker = TXN_ID ( ltid );
-
opinfo.boi_oe.oe_key = bdb;
opinfo.boi_txn = ltid;
opinfo.boi_err = 0;
/* get entry */
rs->sr_err = bdb_dn2entry( op, ltid, &op->o_req_ndn, &ei, 1,
- locker, &lock );
+ &lock );
switch( rs->sr_err ) {
case 0:
* children.
*/
rs->sr_err = bdb_cache_find_id( op, ltid,
- eip->bei_id, &eip, 0, locker, &plock );
+ eip->bei_id, &eip, 0, &plock );
switch( rs->sr_err ) {
case 0:
/* Get Entry with dn=newSuperior. Does newSuperior exist? */
rs->sr_err = bdb_dn2entry( op, ltid, np_ndn,
- &neip, 0, locker, &nplock );
+ &neip, 0, &nplock );
switch( rs->sr_err ) {
case 0: np = neip->bei_e;
/* Shortcut the search */
nei = neip ? neip : eip;
- rs->sr_err = bdb_cache_find_ndn ( op, locker, &new_ndn, &nei );
+ rs->sr_err = bdb_cache_find_ndn ( op, ltid, &new_ndn, &nei );
if ( nei ) bdb_cache_entryinfo_unlock( nei );
switch( rs->sr_err ) {
case DB_LOCK_DEADLOCK:
} else {
rc = bdb_cache_modrdn( bdb, e, &op->orr_nnewrdn, &dummy, neip,
- locker, &lock );
+ ltid, &lock );
switch( rc ) {
case DB_LOCK_DEADLOCK:
case DB_LOCK_NOTGRANTED:
int bdb_dn2entry LDAP_P(( Operation *op, DB_TXN *tid,
struct berval *dn, EntryInfo **e, int matched,
- BDB_LOCKER locker, DB_LOCK *lock ));
+ DB_LOCK *lock ));
/*
* dn2id.c
Operation *op,
struct berval *dn,
EntryInfo *ei,
- BDB_LOCKER locker,
+ DB_TXN *txn,
DB_LOCK *lock );
int bdb_dn2id_add(
int bdb_dn2idl(
Operation *op,
- BDB_LOCKER locker,
+ DB_TXN *txn,
struct berval *ndn,
EntryInfo *ei,
ID *ids,
int bdb_dn2id_parent(
Operation *op,
- BDB_LOCKER locker,
+ DB_TXN *txn,
EntryInfo *ei,
ID *idp );
int bdb_filter_candidates(
Operation *op,
- BDB_LOCKER locker,
+ DB_TXN *txn,
Filter *f,
ID *ids,
ID *tmp,
int bdb_id2entry(
BackendDB *be,
DB_TXN *tid,
- BDB_LOCKER locker,
ID id,
Entry **e);
#endif
int bdb_idl_fetch_key(
BackendDB *be,
DB *db,
- BDB_LOCKER locker,
+ DB_TXN *txn,
DBT *key,
ID *ids,
DBC **saved_cursor,
bdb_key_read(
Backend *be,
DB *db,
- BDB_LOCKER locker,
+ DB_TXN *txn,
struct berval *k,
ID *ids,
DBC **saved_cursor,
EntryInfo *pei,
Entry *e,
struct berval *nrdn,
- BDB_LOCKER locker,
+ DB_TXN *txn,
DB_LOCK *lock
);
int bdb_cache_modrdn(
struct berval *nrdn,
Entry *new,
EntryInfo *ein,
- BDB_LOCKER locker,
+ DB_TXN *txn,
DB_LOCK *lock
);
int bdb_cache_modify(
struct bdb_info *bdb,
Entry *e,
Attribute *newAttrs,
- BDB_LOCKER locker,
+ DB_TXN *txn,
DB_LOCK *lock
);
int bdb_cache_find_ndn(
Operation *op,
- BDB_LOCKER locker,
+ DB_TXN *txn,
struct berval *ndn,
EntryInfo **res
);
ID id,
EntryInfo **eip,
int flag,
- BDB_LOCKER locker,
DB_LOCK *lock
);
int
bdb_cache_find_parent(
Operation *op,
- BDB_LOCKER locker,
+ DB_TXN *txn,
ID id,
EntryInfo **res
);
int bdb_cache_delete(
struct bdb_info *bdb,
Entry *e,
- BDB_LOCKER locker,
+ DB_TXN *txn,
DB_LOCK *lock
);
void bdb_cache_delete_cleanup(
#define bdb_cache_entry_db_relock BDB_SYMBOL(cache_entry_db_relock)
int bdb_cache_entry_db_relock(
struct bdb_info *bdb,
- BDB_LOCKER locker,
+ DB_TXN *txn,
EntryInfo *ei,
int rw,
int tryOnly,
struct bdb_info *bdb,
DB_LOCK *lock );
-#ifdef BDB_REUSE_LOCKERS
-
-#define bdb_locker_id BDB_SYMBOL(locker_id)
-#define bdb_locker_flush BDB_SYMBOL(locker_flush)
-int bdb_locker_id( Operation *op, DB_ENV *env, BDB_LOCKER *locker );
-void bdb_locker_flush( DB_ENV *env );
-
-#define LOCK_ID_FREE(env, locker) ((void)0)
-#define LOCK_ID(env, locker) bdb_locker_id(op, env, locker)
-
-#else
-
-#define LOCK_ID_FREE(env, locker) XLOCK_ID_FREE(env, locker)
-#define LOCK_ID(env, locker) XLOCK_ID(env, locker)
-
-#endif
+#define bdb_reader_get BDB_SYMBOL(reader_get)
+#define bdb_reader_flush BDB_SYMBOL(reader_flush)
+int bdb_reader_get( Operation *op, DB_ENV *env, DB_TXN **txn );
+void bdb_reader_flush( DB_ENV *env );
/*
* trans.c
EntryInfo *ei;
int rc = LDAP_SUCCESS;
- BDB_LOCKER locker;
+ DB_TXN *rtxn;
DB_LOCK lock;
if( op->o_tag == LDAP_REQ_SEARCH ) {
return rc;
}
- rc = LOCK_ID(bdb->bi_dbenv, &locker);
+ rc = bdb_reader_get(op, bdb->bi_dbenv, &rtxn);
switch(rc) {
case 0:
break;
dn2entry_retry:
/* get entry */
- rc = bdb_dn2entry( op, NULL, &op->o_req_ndn, &ei, 1, locker, &lock );
+ rc = bdb_dn2entry( op, rtxn, &op->o_req_ndn, &ei, 1, &lock );
/* bdb_dn2entry() may legally leave ei == NULL
* if rc != 0 and rc != DB_NOTFOUND
case 0:
break;
case LDAP_BUSY:
- LOCK_ID_FREE ( bdb->bi_dbenv, locker );
rs->sr_text = "ldap server busy";
return LDAP_BUSY;
case DB_LOCK_DEADLOCK:
LDAP_XSTRING(bdb_referrals)
": dn2entry failed: %s (%d)\n",
db_strerror(rc), rc, 0 );
- LOCK_ID_FREE ( bdb->bi_dbenv, locker );
rs->sr_text = "internal error";
return LDAP_OTHER;
}
rs->sr_text = rs->sr_matched ? "bad referral object" : NULL;
}
- LOCK_ID_FREE ( bdb->bi_dbenv, locker );
if (rs->sr_matched) {
op->o_tmpfree( (char *)rs->sr_matched, op->o_tmpmemctx );
rs->sr_matched = NULL;
}
bdb_cache_return_entry_r(bdb, e, &lock);
- LOCK_ID_FREE ( bdb->bi_dbenv, locker );
return rc;
}
Operation *op,
SlapReply *rs,
Entry *e,
- BDB_LOCKER locker,
+ DB_TXN *txn,
ID *ids,
ID *scopes );
SlapReply *rs,
Entry *e,
Entry **matched,
- BDB_LOCKER locker,
+ DB_TXN *txn,
DB_LOCK *lock,
ID *tmp,
ID *visited )
break;
}
- rs->sr_err = bdb_dn2entry( op, NULL, &ndn, &ei,
- 0, locker, &lockr );
+ rs->sr_err = bdb_dn2entry( op, txn, &ndn, &ei,
+ 0, &lockr );
if ( ei ) {
e = ei->bei_e;
Operation *op,
SlapReply *rs,
Entry *e,
- BDB_LOCKER locker,
+ DB_TXN *txn,
ID *ids,
ID *scopes,
ID *stack )
/* Find all aliases in database */
BDB_IDL_ZERO( aliases );
- rs->sr_err = bdb_filter_candidates( op, locker, &af, aliases,
+ rs->sr_err = bdb_filter_candidates( op, txn, &af, aliases,
curscop, visited );
if (rs->sr_err != LDAP_SUCCESS) {
return rs->sr_err;
* to the cumulative list of candidates.
*/
BDB_IDL_CPY( curscop, aliases );
- rs->sr_err = bdb_dn2idl( op, locker, &e->e_nname, BEI(e), subscop,
+ rs->sr_err = bdb_dn2idl( op, txn, &e->e_nname, BEI(e), subscop,
subscop2+BDB_IDL_DB_SIZE );
if (first) {
first = 0;
{
ei = NULL;
retry1:
- rs->sr_err = bdb_cache_find_id(op, NULL,
- ida, &ei, 0, locker, &lockr );
+ rs->sr_err = bdb_cache_find_id(op, txn,
+ ida, &ei, 0, &lockr );
if (rs->sr_err != LDAP_SUCCESS) {
if ( rs->sr_err == DB_LOCK_DEADLOCK ||
rs->sr_err == DB_LOCK_NOTGRANTED ) goto retry1;
/* Actually dereference the alias */
BDB_IDL_ZERO(tmp);
- a = deref_base( op, rs, a, &matched, locker, &lockr,
+ a = deref_base( op, rs, a, &matched, txn, &lockr,
tmp, visited );
if (a) {
/* If the target was not already in our current candidates,
*/
ei = NULL;
sameido:
- rs->sr_err = bdb_cache_find_id(op, NULL, ido, &ei,
- 0, locker, &locka );
+ rs->sr_err = bdb_cache_find_id(op, txn, ido, &ei,
+ 0, &locka );
if ( rs->sr_err != LDAP_SUCCESS ) {
if ( rs->sr_err == DB_LOCK_DEADLOCK ||
rs->sr_err == DB_LOCK_NOTGRANTED )
int tentries = 0, nentries = 0;
int idflag = 0;
- BDB_LOCKER locker = 0;
DB_LOCK lock;
struct bdb_op_info *opinfo = NULL;
DB_TXN *ltid = NULL;
if ( opinfo && opinfo->boi_txn ) {
ltid = opinfo->boi_txn;
- locker = TXN_ID( ltid );
} else {
- rs->sr_err = LOCK_ID( bdb->bi_dbenv, &locker );
+ rs->sr_err = bdb_reader_get( op, bdb->bi_dbenv, <id );
switch(rs->sr_err) {
case 0:
dn2entry_retry:
/* get entry with reader lock */
rs->sr_err = bdb_dn2entry( op, ltid, &op->o_req_ndn, &ei,
- 1, locker, &lock );
+ 1, &lock );
}
switch(rs->sr_err) {
break;
case LDAP_BUSY:
send_ldap_error( op, rs, LDAP_BUSY, "ldap server busy" );
- if ( !opinfo )
- LOCK_ID_FREE (bdb->bi_dbenv, locker );
return LDAP_BUSY;
case DB_LOCK_DEADLOCK:
case DB_LOCK_NOTGRANTED:
goto dn2entry_retry;
default:
send_ldap_error( op, rs, LDAP_OTHER, "internal error" );
- if ( !opinfo )
- LOCK_ID_FREE (bdb->bi_dbenv, locker );
return rs->sr_err;
}
stub.bv_val = op->o_req_ndn.bv_val;
stub.bv_len = op->o_req_ndn.bv_len - matched->e_nname.bv_len - 1;
- e = deref_base( op, rs, matched, &matched, locker, &lock,
+ e = deref_base( op, rs, matched, &matched, ltid, &lock,
candidates, NULL );
if ( e ) {
build_new_dn( &op->o_req_ndn, &e->e_nname, &stub,
goto dn2entry_retry;
}
} else if ( e && is_entry_alias( e )) {
- e = deref_base( op, rs, e, &matched, locker, &lock,
+ e = deref_base( op, rs, e, &matched, ltid, &lock,
candidates, NULL );
}
}
send_ldap_result( op, rs );
- if ( !opinfo )
- LOCK_ID_FREE (bdb->bi_dbenv, locker );
if ( rs->sr_ref ) {
ber_bvarray_free( rs->sr_ref );
rs->sr_ref = NULL;
rs->sr_matched = matched_dn.bv_val;
send_ldap_result( op, rs );
- if ( !opinfo ) {
- LOCK_ID_FREE (bdb->bi_dbenv, locker );
- }
ber_bvarray_free( rs->sr_ref );
rs->sr_ref = NULL;
ber_memfree( matched_dn.bv_val );
BDB_IDL_ZERO( candidates );
BDB_IDL_ZERO( scopes );
rs->sr_err = search_candidates( op, rs, &base,
- locker, candidates, scopes );
+ ltid, candidates, scopes );
}
/* start cursor at beginning of candidates.
/* get the entry with reader lock */
ei = NULL;
rs->sr_err = bdb_cache_find_id( op, ltid,
- id, &ei, idflag, locker, &lock );
+ id, &ei, idflag, &lock );
if (rs->sr_err == LDAP_BUSY) {
rs->sr_text = "ldap server busy";
rs->sr_err = LDAP_SUCCESS;
done:
- if ( !opinfo )
- LOCK_ID_FREE( bdb->bi_dbenv, locker );
-
if( rs->sr_v2ref ) {
ber_bvarray_free( rs->sr_v2ref );
rs->sr_v2ref = NULL;
Operation *op,
SlapReply *rs,
Entry *e,
- BDB_LOCKER locker,
+ DB_TXN *txn,
ID *ids,
ID *scopes )
{
}
if( op->ors_deref & LDAP_DEREF_SEARCHING ) {
- rc = search_aliases( op, rs, e, locker, ids, scopes, stack );
+ rc = search_aliases( op, rs, e, txn, ids, scopes, stack );
} else {
- rc = bdb_dn2idl( op, locker, &e->e_nname, BEI(e), ids, stack );
+ rc = bdb_dn2idl( op, txn, &e->e_nname, BEI(e), ids, stack );
}
if ( rc == LDAP_SUCCESS ) {
- rc = bdb_filter_candidates( op, locker, &f, ids,
+ rc = bdb_filter_candidates( op, txn, &f, ids,
stack, stack+BDB_IDL_UM_SIZE );
}
if (cursor == NULL) {
int rc = bdb->bi_id2entry->bdi_db->cursor(
- bdb->bi_id2entry->bdi_db, NULL, &cursor,
+ bdb->bi_id2entry->bdi_db, bdb->bi_cache.c_txn, &cursor,
bdb->bi_db_opflags );
if( rc != 0 ) {
return -1;
Entry* bdb_tool_entry_get( BackendDB *be, ID id )
{
+ struct bdb_info *bdb = (struct bdb_info *) be->be_private;
Entry *e = NULL;
char *dptr;
int rc, eoff;
op.o_tmpmemctx = NULL;
op.o_tmpmfuncs = &ch_mfuncs;
- rc = bdb_cache_find_parent( &op, CURSOR_GETLOCKER(cursor), id, &ei );
+ rc = bdb_cache_find_parent( &op, bdb->bi_cache.c_txn, id, &ei );
if ( rc == LDAP_SUCCESS ) {
bdb_cache_entryinfo_unlock( ei );
e->e_private = ei;
return 0;
}
- rc = bdb_cache_find_ndn( op, tid ? TXN_ID( tid ) : 0, &ndn, &ei );
+ rc = bdb_cache_find_ndn( op, tid, &ndn, &ei );
if ( ei ) bdb_cache_entryinfo_unlock( ei );
if ( rc == DB_NOTFOUND ) {
if ( !be_issuffix( op->o_bd, &ndn ) ) {