use of pre-assigned locker in bdb_group() / bdb_attribute()

This commit is contained in:
Jong Hyuk Choi 2003-02-07 15:47:32 +00:00
parent 6cf0c94845
commit 55cf8bbd88
10 changed files with 44 additions and 23 deletions

View file

@ -34,7 +34,7 @@ bdb_add(
#ifdef BDB_SUBENTRIES
int subentry;
#endif
u_int32_t locker;
u_int32_t locker = 0;
DB_LOCK lock;
#if 0
u_int32_t lockid;
@ -132,6 +132,7 @@ retry: /* transaction retry */
opinfo.boi_bdb = be;
opinfo.boi_txn = ltid;
opinfo.boi_locker = locker;
opinfo.boi_err = 0;
op->o_private = &opinfo;

View file

@ -39,8 +39,9 @@ bdb_attribute(
const char *entry_at_name = entry_at->ad_cname.bv_val;
AccessControlState acl_state = ACL_STATE_INIT;
u_int32_t locker;
u_int32_t locker = 0;
DB_LOCK lock;
int free_lock_id = 0;
#ifdef NEW_LOGGING
LDAP_LOG( BACK_BDB, ARGS,
@ -65,12 +66,14 @@ bdb_attribute(
if( op ) boi = (struct bdb_op_info *) op->o_private;
if( boi != NULL && be == boi->boi_bdb ) {
txn = boi->boi_txn;
locker = boi->boi_locker;
}
if ( txn != NULL ) {
locker = TXN_ID ( txn );
} else {
} else if ( !locker ) {
rc = LOCK_ID ( bdb->bi_dbenv, &locker );
free_lock_id = 1;
switch(rc) {
case 0:
break;
@ -103,10 +106,8 @@ dn2entry_retry:
case DB_LOCK_NOTGRANTED:
goto dn2entry_retry;
default:
if( txn != NULL ) {
boi->boi_err = rc;
}
else {
boi->boi_err = rc;
if ( free_lock_id ) {
LOCK_ID_FREE( bdb->bi_dbenv, locker );
}
return (rc != LDAP_BUSY) ? LDAP_OTHER : LDAP_BUSY;
@ -121,7 +122,7 @@ dn2entry_retry:
"=> bdb_attribute: cannot find entry: \"%s\"\n",
entry_ndn->bv_val, 0, 0 );
#endif
if ( txn == NULL ) {
if ( free_lock_id ) {
LOCK_ID_FREE( bdb->bi_dbenv, locker );
}
return LDAP_NO_SUCH_OBJECT;
@ -221,7 +222,7 @@ return_results:
bdb_cache_return_entry_r(bdb->bi_dbenv, &bdb->bi_cache, e, &lock);
}
if ( txn == NULL ) {
if ( free_lock_id ) {
LOCK_ID_FREE( bdb->bi_dbenv, locker );
}

View file

@ -155,7 +155,8 @@ struct bdb_info {
struct bdb_op_info {
BackendDB* boi_bdb;
DB_TXN* boi_txn;
int boi_err;
u_int32_t boi_err;
u_int32_t boi_locker;
};
#define DB_OPEN(db, file, name, type, flags, mode) \

View file

@ -35,7 +35,7 @@ bdb_delete(
DB_TXN *ltid = NULL;
struct bdb_op_info opinfo;
u_int32_t locker;
u_int32_t locker = 0;
DB_LOCK lock;
#if 0
u_int32_t lockid;
@ -104,6 +104,7 @@ retry: /* transaction retry */
opinfo.boi_bdb = be;
opinfo.boi_txn = ltid;
opinfo.boi_locker = locker;
opinfo.boi_err = 0;
op->o_private = &opinfo;

View file

@ -42,8 +42,9 @@ bdb_group(
const char *group_oc_name = NULL;
const char *group_at_name = group_at->ad_cname.bv_val;
u_int32_t locker;
u_int32_t locker = 0;
DB_LOCK lock;
int free_lock_id = 0;
if( group_oc->soc_names && group_oc->soc_names[0] ) {
group_oc_name = group_oc->soc_names[0];
@ -51,6 +52,8 @@ bdb_group(
group_oc_name = group_oc->soc_oid;
}
printf("KKK\n");
#ifdef NEW_LOGGING
LDAP_LOG( BACK_BDB, ENTRY,
"bdb_group: check (%s) member of (%s), oc %s\n",
@ -76,12 +79,14 @@ bdb_group(
if( op ) boi = (struct bdb_op_info *) op->o_private;
if( boi != NULL && be == boi->boi_bdb ) {
txn = boi->boi_txn;
locker = boi->boi_locker;
}
if ( txn ) {
locker = TXN_ID( txn );
} else {
} else if ( !locker ) {
rc = LOCK_ID ( bdb->bi_dbenv, &locker );
free_lock_id = 1;
switch(rc) {
case 0:
break;
@ -108,10 +113,8 @@ dn2entry_retry:
if( rc ) {
if ( rc == DB_LOCK_DEADLOCK || rc == DB_LOCK_NOTGRANTED )
goto dn2entry_retry;
if( txn ) {
boi->boi_err = rc;
}
else {
boi->boi_err = rc;
if ( free_lock_id ) {
LOCK_ID_FREE ( bdb->bi_dbenv, locker );
}
return( 1 );
@ -125,7 +128,7 @@ dn2entry_retry:
"=> bdb_group: cannot find group: \"%s\"\n",
gr_ndn->bv_val, 0, 0 );
#endif
if ( txn == NULL ) {
if ( free_lock_id ) {
LOCK_ID_FREE ( bdb->bi_dbenv, locker );
}
return( 1 );
@ -236,7 +239,7 @@ return_results:
bdb_cache_return_entry_r( bdb->bi_dbenv, &bdb->bi_cache, e, &lock );
}
if ( txn == NULL ) {
if ( free_lock_id ) {
LOCK_ID_FREE ( bdb->bi_dbenv, locker );
}

View file

@ -272,7 +272,7 @@ bdb_modify(
DB_TXN *ltid = NULL;
struct bdb_op_info opinfo;
u_int32_t locker;
u_int32_t locker = 0;
DB_LOCK lock;
int noop = 0;
@ -345,6 +345,7 @@ retry: /* transaction retry */
opinfo.boi_bdb = be;
opinfo.boi_txn = ltid;
opinfo.boi_locker = locker;
opinfo.boi_err = 0;
op->o_private = &opinfo;

View file

@ -57,7 +57,7 @@ bdb_modrdn(
int manageDSAit = get_manageDSAit( op );
u_int32_t locker;
u_int32_t locker = 0;
DB_LOCK lock;
int noop = 0;
@ -139,6 +139,7 @@ retry: /* transaction retry */
opinfo.boi_bdb = be;
opinfo.boi_txn = ltid;
opinfo.boi_locker = locker;
opinfo.boi_err = 0;
op->o_private = &opinfo;

View file

@ -77,6 +77,7 @@ retry: /* transaction retry */
opinfo.boi_bdb = be;
opinfo.boi_txn = ltid;
opinfo.boi_locker = TXN_ID ( ltid );
opinfo.boi_err = 0;
op->o_private = &opinfo;

View file

@ -41,7 +41,7 @@ bdb_exop_passwd(
struct berval dn;
struct berval ndn;
u_int32_t locker;
u_int32_t locker = 0;
DB_LOCK lock;
assert( reqoid != NULL );
@ -153,6 +153,7 @@ retry: /* transaction retry */
opinfo.boi_bdb = be;
opinfo.boi_txn = ltid;
opinfo.boi_locker = locker;
opinfo.boi_err = 0;
op->o_private = &opinfo;

View file

@ -83,8 +83,9 @@ bdb_search(
struct slap_limits_set *limit = NULL;
int isroot = 0;
u_int32_t locker;
u_int32_t locker = 0;
DB_LOCK lock;
struct bdb_op_info opinfo;
#ifdef NEW_LOGGING
LDAP_LOG ( OPERATION, ENTRY, "bdb_back_search\n", 0, 0, 0 );
@ -127,6 +128,9 @@ bdb_search(
pagedresults = get_pagedresults( op );
rc = LOCK_ID (bdb->bi_dbenv, &locker );
printf("locker = %d\n", locker);
switch(rc) {
case 0:
break;
@ -136,6 +140,12 @@ bdb_search(
return rc;
}
opinfo.boi_bdb = be;
opinfo.boi_txn = NULL;
opinfo.boi_locker = locker;
opinfo.boi_err = 0;
op->o_private = &opinfo;
if ( nbase->bv_len == 0 ) {
/* DIT root special case */
e = (Entry *) &slap_entry_root;