From 55cf8bbd88c7bac0586887a78aaa01e8ad7f9171 Mon Sep 17 00:00:00 2001 From: Jong Hyuk Choi Date: Fri, 7 Feb 2003 15:47:32 +0000 Subject: [PATCH] use of pre-assigned locker in bdb_group() / bdb_attribute() --- servers/slapd/back-bdb/add.c | 3 ++- servers/slapd/back-bdb/attribute.c | 17 +++++++++-------- servers/slapd/back-bdb/back-bdb.h | 3 ++- servers/slapd/back-bdb/delete.c | 3 ++- servers/slapd/back-bdb/group.c | 19 +++++++++++-------- servers/slapd/back-bdb/modify.c | 3 ++- servers/slapd/back-bdb/modrdn.c | 3 ++- servers/slapd/back-bdb/operational.c | 1 + servers/slapd/back-bdb/passwd.c | 3 ++- servers/slapd/back-bdb/search.c | 12 +++++++++++- 10 files changed, 44 insertions(+), 23 deletions(-) diff --git a/servers/slapd/back-bdb/add.c b/servers/slapd/back-bdb/add.c index 8bc54ede34..3e85b1a7ad 100644 --- a/servers/slapd/back-bdb/add.c +++ b/servers/slapd/back-bdb/add.c @@ -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; diff --git a/servers/slapd/back-bdb/attribute.c b/servers/slapd/back-bdb/attribute.c index 375fe35347..d2b2bb5a32 100644 --- a/servers/slapd/back-bdb/attribute.c +++ b/servers/slapd/back-bdb/attribute.c @@ -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 ); } diff --git a/servers/slapd/back-bdb/back-bdb.h b/servers/slapd/back-bdb/back-bdb.h index e306c86438..5a28d25581 100644 --- a/servers/slapd/back-bdb/back-bdb.h +++ b/servers/slapd/back-bdb/back-bdb.h @@ -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) \ diff --git a/servers/slapd/back-bdb/delete.c b/servers/slapd/back-bdb/delete.c index e31f250f81..79cb460843 100644 --- a/servers/slapd/back-bdb/delete.c +++ b/servers/slapd/back-bdb/delete.c @@ -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; diff --git a/servers/slapd/back-bdb/group.c b/servers/slapd/back-bdb/group.c index 174cd4876c..e0099af0c3 100644 --- a/servers/slapd/back-bdb/group.c +++ b/servers/slapd/back-bdb/group.c @@ -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 ); } diff --git a/servers/slapd/back-bdb/modify.c b/servers/slapd/back-bdb/modify.c index 400b143596..8df7b7b5cc 100644 --- a/servers/slapd/back-bdb/modify.c +++ b/servers/slapd/back-bdb/modify.c @@ -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; diff --git a/servers/slapd/back-bdb/modrdn.c b/servers/slapd/back-bdb/modrdn.c index 23d4d6cb84..8fcba26ffd 100644 --- a/servers/slapd/back-bdb/modrdn.c +++ b/servers/slapd/back-bdb/modrdn.c @@ -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; diff --git a/servers/slapd/back-bdb/operational.c b/servers/slapd/back-bdb/operational.c index 5a1a394e59..ca87a6c727 100644 --- a/servers/slapd/back-bdb/operational.c +++ b/servers/slapd/back-bdb/operational.c @@ -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; diff --git a/servers/slapd/back-bdb/passwd.c b/servers/slapd/back-bdb/passwd.c index 74e03d8f9d..87451ba307 100644 --- a/servers/slapd/back-bdb/passwd.c +++ b/servers/slapd/back-bdb/passwd.c @@ -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; diff --git a/servers/slapd/back-bdb/search.c b/servers/slapd/back-bdb/search.c index 14df815a20..cd25b0485b 100644 --- a/servers/slapd/back-bdb/search.c +++ b/servers/slapd/back-bdb/search.c @@ -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; -- 2.39.5