DB_TXN *ltid = NULL, *lt2;
struct bdb_op_info opinfo = {0};
int subentry;
- u_int32_t locker = 0, rlocker = 0;
+ BDB_LOCKER locker = 0, rlocker = 0;
DB_LOCK lock;
int num_retries = 0;
#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
+#else
+
+typedef u_int32_t BDB_LOCKER;
+
+#define CURSOR_SETLOCKER(cursor, id) cursor->locker = id
+#define CURSOR_GETLOCKER(cursor) cursor->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;
- u_int32_t c_locker; /* used by lru cleaner */
+ BDB_LOCKER c_locker; /* 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;
#define bi_id2entry bi_databases[BDB_ID2ENTRY]
#define bi_dn2id bi_databases[BDB_DN2ID]
+
struct bdb_lock_info {
struct bdb_lock_info *bli_next;
ID bli_id;
struct bdb_op_info {
BackendDB* boi_bdb;
DB_TXN* boi_txn;
+ BDB_LOCKER boi_locker;
u_int32_t boi_err;
- u_int32_t boi_locker;
int boi_acl_cache;
struct bdb_lock_info *boi_locks; /* used when no txn */
};
((db)->open)(db, NULL, file, name, type, flags, mode)
#endif
-#endif
-
-/* 4.6.18 redefines cursor->locker */
+/* 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
-struct __db_locker {
- u_int32_t id;
-};
-
-extern int __lock_getlocker(DB_LOCKTAB *lt, u_int32_t locker, int create, DB_LOCKER **ret);
-
-#define CURSOR_SETLOCKER(cursor, id) \
- __lock_getlocker(cursor->dbp->dbenv->lk_handle, id, 0, &cursor->locker)
-#define CURSOR_GETLOCKER(cursor) cursor->locker->id
-#else
-#define CURSOR_SETLOCKER(cursor, id) cursor->locker = id
-#define CURSOR_GETLOCKER(cursor) cursor->locker
#endif
#ifndef DB_BUFFER_SMALL
AttributeDescription *password = slap_schema.si_ad_userPassword;
- u_int32_t locker;
+ BDB_LOCKER locker;
DB_LOCK lock;
Debug( LDAP_DEBUG_ARGS,
* alternatives though.
*/
+#if DB_VERSION_FULL >= 0x04060012
+#define BDB_LOCKID(locker) locker->id
+#else
+#define BDB_LOCKID(locker) locker
+#endif
+
/* Atomically release and reacquire a lock */
int
bdb_cache_entry_db_relock(
struct bdb_info *bdb,
- u_int32_t locker,
+ BDB_LOCKER locker,
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, locker, tryOnly ? DB_LOCK_NOWAIT : 0,
+ rc = bdb->bi_dbenv->lock_vec(bdb->bi_dbenv, BDB_LOCKID(locker), tryOnly ? DB_LOCK_NOWAIT : 0,
list, 2, NULL );
if (rc && !tryOnly) {
}
static int
-bdb_cache_entry_db_lock( struct bdb_info *bdb, u_int32_t locker, EntryInfo *ei,
+bdb_cache_entry_db_lock( struct bdb_info *bdb, BDB_LOCKER 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(bdb->bi_dbenv, locker, tryOnly ? DB_LOCK_NOWAIT : 0,
+ rc = LOCK_GET(bdb->bi_dbenv, BDB_LOCKID(locker), tryOnly ? DB_LOCK_NOWAIT : 0,
&lockobj, db_rw, lock);
if (rc && !tryOnly) {
Debug( LDAP_DEBUG_TRACE,
hdb_cache_find_parent(
Operation *op,
DB_TXN *txn,
- u_int32_t locker,
+ BDB_LOCKER locker,
ID id,
EntryInfo **res )
{
ID id,
EntryInfo **eip,
int islocked,
- u_int32_t locker,
+ BDB_LOCKER locker,
DB_LOCK *lock )
{
struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
EntryInfo *eip,
Entry *e,
struct berval *nrdn,
- u_int32_t locker,
+ BDB_LOCKER locker,
DB_LOCK *lock )
{
EntryInfo *new, ei;
struct bdb_info *bdb,
Entry *e,
Attribute *newAttrs,
- u_int32_t locker,
+ BDB_LOCKER locker,
DB_LOCK *lock )
{
EntryInfo *ei = BEI(e);
struct berval *nrdn,
Entry *new,
EntryInfo *ein,
- u_int32_t locker,
+ BDB_LOCKER locker,
DB_LOCK *lock )
{
EntryInfo *ei = BEI(e), *pei;
bdb_cache_delete(
struct bdb_info *bdb,
Entry *e,
- u_int32_t locker,
+ BDB_LOCKER locker,
DB_LOCK *lock )
{
EntryInfo *ei = BEI(e);
bdb_locker_id_free( void *key, void *data )
{
DB_ENV *env = key;
- u_int32_t lockid = (long)data;
+ u_int32_t lockid;
int rc;
+#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;
}
int
-bdb_locker_id( Operation *op, DB_ENV *env, u_int32_t *locker )
+bdb_locker_id( Operation *op, DB_ENV *env, BDB_LOCKER *locker )
{
int i, rc;
u_int32_t lockid;
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
if ( ( rc = ldap_pvt_thread_pool_setkey( ctx, env,
data, bdb_locker_id_free ) ) ) {
XLOCK_ID_FREE( env, lockid );
} else {
lockid = (long)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 );
- u_int32_t locker;
+ BDB_LOCKER locker;
DB_LOCK lock;
rs->sr_err = LOCK_ID(bdb->bi_dbenv, &locker);
DBT key, data;
DB_TXN *txn;
DB_LOCK lock;
- u_int32_t locker;
+ BDB_LOCKER locker;
ID id, nid;
EntryInfo *ei;
int rc, getnext = 1;
struct bdb_op_info opinfo = {0};
ID eid;
- u_int32_t locker = 0;
+ BDB_LOCKER locker = 0;
DB_LOCK lock, plock;
int num_retries = 0;
struct berval *dn,
EntryInfo **e,
int matched,
- u_int32_t locker,
+ BDB_LOCKER locker,
DB_LOCK *lock )
{
EntryInfo *ei = NULL;
int
bdb_dn2idl(
Operation *op,
- u_int32_t locker,
+ BDB_LOCKER locker,
struct berval *ndn,
EntryInfo *ei,
ID *ids,
hdb_dn2id_parent(
Operation *op,
DB_TXN *txn,
- u_int32_t locker,
+ BDB_LOCKER locker,
EntryInfo *ei,
ID *idp )
{
struct dn2id_cookie {
struct bdb_info *bdb;
Operation *op;
- u_int32_t locker;
+ BDB_LOCKER locker;
EntryInfo *ei;
ID *ids;
ID *tmp;
int
hdb_dn2idl(
Operation *op,
- u_int32_t locker,
+ BDB_LOCKER locker,
struct berval *ndn,
EntryInfo *ei,
ID *ids,
static int presence_candidates(
Operation *op,
- u_int32_t locker,
+ BDB_LOCKER locker,
AttributeDescription *desc,
ID *ids );
static int equality_candidates(
Operation *op,
- u_int32_t locker,
+ BDB_LOCKER locker,
AttributeAssertion *ava,
ID *ids,
ID *tmp );
static int inequality_candidates(
Operation *op,
- u_int32_t locker,
+ BDB_LOCKER locker,
AttributeAssertion *ava,
ID *ids,
ID *tmp,
int gtorlt );
static int approx_candidates(
Operation *op,
- u_int32_t locker,
+ BDB_LOCKER locker,
AttributeAssertion *ava,
ID *ids,
ID *tmp );
static int substring_candidates(
Operation *op,
- u_int32_t locker,
+ BDB_LOCKER locker,
SubstringsAssertion *sub,
ID *ids,
ID *tmp );
static int list_candidates(
Operation *op,
- u_int32_t locker,
+ BDB_LOCKER locker,
Filter *flist,
int ftype,
ID *ids,
static int
ext_candidates(
Operation *op,
- u_int32_t locker,
+ BDB_LOCKER locker,
MatchingRuleAssertion *mra,
ID *ids,
ID *tmp,
static int
comp_candidates (
Operation *op,
- u_int32_t locker,
+ BDB_LOCKER locker,
MatchingRuleAssertion *mra,
ComponentFilter *f,
ID *ids,
static int
ava_comp_candidates (
Operation *op,
- u_int32_t locker,
+ BDB_LOCKER locker,
AttributeAssertion *ava,
AttributeAliasing *aa,
ID *ids,
int
bdb_filter_candidates(
Operation *op,
- u_int32_t locker,
+ BDB_LOCKER locker,
Filter *f,
ID *ids,
ID *tmp,
static int
comp_list_candidates(
Operation *op,
- u_int32_t locker,
+ BDB_LOCKER locker,
MatchingRuleAssertion* mra,
ComponentFilter *flist,
int ftype,
static int
comp_equality_candidates (
Operation *op,
- u_int32_t locker,
+ BDB_LOCKER locker,
MatchingRuleAssertion *mra,
ComponentAssertion *ca,
ID *ids,
static int
ava_comp_candidates (
Operation *op,
- u_int32_t locker,
+ BDB_LOCKER locker,
AttributeAssertion *ava,
AttributeAliasing *aa,
ID *ids,
static int
comp_candidates (
Operation *op,
- u_int32_t locker,
+ BDB_LOCKER locker,
MatchingRuleAssertion *mra,
ComponentFilter *f,
ID *ids,
static int
ext_candidates(
Operation *op,
- u_int32_t locker,
+ BDB_LOCKER locker,
MatchingRuleAssertion *mra,
ID *ids,
ID *tmp,
static int
list_candidates(
Operation *op,
- u_int32_t locker,
+ BDB_LOCKER locker,
Filter *flist,
int ftype,
ID *ids,
static int
presence_candidates(
Operation *op,
- u_int32_t locker,
+ BDB_LOCKER locker,
AttributeDescription *desc,
ID *ids )
{
static int
equality_candidates(
Operation *op,
- u_int32_t locker,
+ BDB_LOCKER locker,
AttributeAssertion *ava,
ID *ids,
ID *tmp )
static int
approx_candidates(
Operation *op,
- u_int32_t locker,
+ BDB_LOCKER locker,
AttributeAssertion *ava,
ID *ids,
ID *tmp )
static int
substring_candidates(
Operation *op,
- u_int32_t locker,
+ BDB_LOCKER locker,
SubstringsAssertion *sub,
ID *ids,
ID *tmp )
static int
inequality_candidates(
Operation *op,
- u_int32_t locker,
+ BDB_LOCKER locker,
AttributeAssertion *ava,
ID *ids,
ID *tmp,
int bdb_id2entry(
BackendDB *be,
DB_TXN *tid,
- u_int32_t locker,
+ BDB_LOCKER locker,
ID id,
Entry **e )
{
int rc;
const char *at_name = at ? at->ad_cname.bv_val : "(null)";
- u_int32_t locker = 0;
+ BDB_LOCKER locker = 0;
DB_LOCK lock;
int free_lock_id = 0;
bdb_idl_fetch_key(
BackendDB *be,
DB *db,
- u_int32_t locker,
+ BDB_LOCKER locker,
DBT *key,
ID *ids,
DBC **saved_cursor,
}
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
}
entry_prealloc( bdb->bi_cache.c_maxsize );
if( bdb->bi_dbenv ) {
/* Free cache locker if we enabled locking */
if ( !( slapMode & SLAP_TOOL_QUICK )) {
+#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;
}
#ifdef BDB_REUSE_LOCKERS
bdb_key_read(
Backend *be,
DB *db,
- u_int32_t locker,
+ BDB_LOCKER locker,
struct berval *k,
ID *ids,
DBC **saved_cursor,
Entry dummy = {0};
int fakeroot = 0;
- u_int32_t locker = 0;
+ BDB_LOCKER locker = 0;
DB_LOCK lock;
int num_retries = 0;
int manageDSAit = get_manageDSAit( op );
- u_int32_t locker = 0;
+ BDB_LOCKER locker = 0;
DB_LOCK lock, plock, nplock;
int num_retries = 0;
int bdb_dn2entry LDAP_P(( Operation *op, DB_TXN *tid,
struct berval *dn, EntryInfo **e, int matched,
- u_int32_t locker, DB_LOCK *lock ));
+ BDB_LOCKER locker, DB_LOCK *lock ));
/*
* dn2id.c
int bdb_dn2idl(
Operation *op,
- u_int32_t locker,
+ BDB_LOCKER locker,
struct berval *ndn,
EntryInfo *ei,
ID *ids,
int bdb_dn2id_parent(
Operation *op,
DB_TXN *txn,
- u_int32_t locker,
+ BDB_LOCKER locker,
EntryInfo *ei,
ID *idp );
int bdb_filter_candidates(
Operation *op,
- u_int32_t locker,
+ BDB_LOCKER locker,
Filter *f,
ID *ids,
ID *tmp,
int bdb_id2entry(
BackendDB *be,
DB_TXN *tid,
- u_int32_t locker,
+ BDB_LOCKER locker,
ID id,
Entry **e);
#endif
int bdb_idl_fetch_key(
BackendDB *be,
DB *db,
- u_int32_t locker,
+ BDB_LOCKER locker,
DBT *key,
ID *ids,
DBC **saved_cursor,
bdb_key_read(
Backend *be,
DB *db,
- u_int32_t locker,
+ BDB_LOCKER locker,
struct berval *k,
ID *ids,
DBC **saved_cursor,
EntryInfo *pei,
Entry *e,
struct berval *nrdn,
- u_int32_t locker,
+ BDB_LOCKER locker,
DB_LOCK *lock
);
int bdb_cache_modrdn(
struct berval *nrdn,
Entry *new,
EntryInfo *ein,
- u_int32_t locker,
+ BDB_LOCKER locker,
DB_LOCK *lock
);
int bdb_cache_modify(
struct bdb_info *bdb,
Entry *e,
Attribute *newAttrs,
- u_int32_t locker,
+ BDB_LOCKER locker,
DB_LOCK *lock
);
int bdb_cache_find_ndn(
ID id,
EntryInfo **eip,
int islocked,
- u_int32_t locker,
+ BDB_LOCKER locker,
DB_LOCK *lock
);
int
bdb_cache_find_parent(
Operation *op,
DB_TXN *txn,
- u_int32_t locker,
+ BDB_LOCKER locker,
ID id,
EntryInfo **res
);
int bdb_cache_delete(
struct bdb_info *bdb,
Entry *e,
- u_int32_t locker,
+ BDB_LOCKER locker,
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,
- u_int32_t locker,
+ BDB_LOCKER locker,
EntryInfo *ei,
int rw,
int tryOnly,
#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, u_int32_t *locker );
+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)
EntryInfo *ei;
int rc = LDAP_SUCCESS;
- u_int32_t locker;
+ BDB_LOCKER locker;
DB_LOCK lock;
if( op->o_tag == LDAP_REQ_SEARCH ) {
Operation *op,
SlapReply *rs,
Entry *e,
- u_int32_t locker,
+ BDB_LOCKER locker,
ID *ids,
ID *scopes );
SlapReply *rs,
Entry *e,
Entry **matched,
- u_int32_t locker,
+ BDB_LOCKER locker,
DB_LOCK *lock,
ID *tmp,
ID *visited )
Operation *op,
SlapReply *rs,
Entry *e,
- u_int32_t locker,
+ BDB_LOCKER locker,
ID *ids,
ID *scopes,
ID *stack )
ID lastid = NOID;
AttributeName *attrs;
- u_int32_t locker = 0;
+ BDB_LOCKER locker = 0;
DB_LOCK lock;
struct bdb_op_info *opinfo = NULL;
DB_TXN *ltid = NULL;
Operation *op,
SlapReply *rs,
Entry *e,
- u_int32_t locker,
+ BDB_LOCKER locker,
ID *ids,
ID *scopes )
{