]> git.sur5r.net Git - openldap/commitdiff
use of pre-assigned locker in bdb_group() / bdb_attribute()
authorJong Hyuk Choi <jongchoi@openldap.org>
Fri, 7 Feb 2003 15:47:32 +0000 (15:47 +0000)
committerJong Hyuk Choi <jongchoi@openldap.org>
Fri, 7 Feb 2003 15:47:32 +0000 (15:47 +0000)
servers/slapd/back-bdb/add.c
servers/slapd/back-bdb/attribute.c
servers/slapd/back-bdb/back-bdb.h
servers/slapd/back-bdb/delete.c
servers/slapd/back-bdb/group.c
servers/slapd/back-bdb/modify.c
servers/slapd/back-bdb/modrdn.c
servers/slapd/back-bdb/operational.c
servers/slapd/back-bdb/passwd.c
servers/slapd/back-bdb/search.c

index 8bc54ede34e28fb781d23d7b3a9ffe68bb550330..3e85b1a7ad04343114f135f79f7bdbb99f916e54 100644 (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;
        
index 375fe353471e215f366d7cbe806fab161ea4d1a1..d2b2bb5a322a9cb277c5f5bd2ee48329e3e06eb9 100644 (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 );
        }
 
index e306c86438edbe534e50496970ad990a24e02121..5a28d25581beda00a009eaa534f845a1a21a0ffd 100644 (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) \
index e31f250f81ff688927d0afad799ddc8124e47803..79cb4608439ce6c7225257a4978302f433f978dd 100644 (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;
 
index 174cd4876cad2d67ab1556b83e7b879fdc5eb1c1..e0099af0c3d9d524770c628a68a80b61b922fa68 100644 (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 );
        }
 
index 400b143596205e79842c570e28f09689679d9f75..8df7b7b5cc54f51a8ce307a4b1ca21f7b1c40a7f 100644 (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;
 
index 23d4d6cb84fc939cedc1752919869e627b00eddc..8fcba26ffd4b93f4c424d95b7229961761aa65d5 100644 (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;
 
index 5a1a394e59b0e3ae3ba36817db1e4408ae3bcac6..ca87a6c7277d8df465513073ab2c3b0d67aa1a41 100644 (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;
 
index 74e03d8f9d081fa4f74706dae092827b5cccdbc4..87451ba30734db2b5b7546820e40bd208e8fe1f6 100644 (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;
 
index 14df815a201e6bb3843a5e5f2b1cec46c6c41704..cd25b0485b806c11127a226133997565eda574b5 100644 (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;