]> git.sur5r.net Git - openldap/commitdiff
Use o_extra instead of o_private
authorQuanah Gibson-Mount <quanah@openldap.org>
Thu, 1 May 2008 23:39:35 +0000 (23:39 +0000)
committerQuanah Gibson-Mount <quanah@openldap.org>
Thu, 1 May 2008 23:39:35 +0000 (23:39 +0000)
servers/slapd/back-bdb/add.c
servers/slapd/back-bdb/back-bdb.h
servers/slapd/back-bdb/cache.c
servers/slapd/back-bdb/delete.c
servers/slapd/back-bdb/id2entry.c
servers/slapd/back-bdb/modify.c
servers/slapd/back-bdb/modrdn.c
servers/slapd/back-bdb/search.c

index b10f7d239ee248c7577bf59891f152bf1bfbc642..36acb47696b76f5e770dc09d2d5d67ed4676dad2 100644 (file)
@@ -93,7 +93,6 @@ txnReturn:
 
        ctrls[num_ctrls] = 0;
 
-
        /* check entry's schema */
        rs->sr_err = entry_schema_check( op, op->oq_add.rs_e, NULL,
                get_relax(op), 1, &rs->sr_text, textbuf, textlen );
@@ -130,7 +129,8 @@ retry:      /* transaction retry */
                }
                rs->sr_err = TXN_ABORT( ltid );
                ltid = NULL;
-               op->o_private = NULL;
+               LDAP_SLIST_REMOVE( &op->o_extra, &opinfo.boi_oe, OpExtra, oe_next );
+               opinfo.boi_oe.oe_key = NULL;
                op->o_do_not_cache = opinfo.boi_acl_cache;
                if( rs->sr_err != 0 ) {
                        rs->sr_err = LDAP_OTHER;
@@ -159,12 +159,12 @@ retry:    /* transaction retry */
 
        locker = TXN_ID ( ltid );
 
-       opinfo.boi_bdb = op->o_bd;
+       opinfo.boi_oe.oe_key = bdb;
        opinfo.boi_txn = ltid;
        opinfo.boi_err = 0;
        opinfo.boi_acl_cache = op->o_do_not_cache;
-       op->o_private = &opinfo;
-       
+       LDAP_SLIST_INSERT_HEAD( &op->o_extra, &opinfo.boi_oe, oe_next );
+
        /*
         * Get the parent dn and see if the corresponding entry exists.
         */
@@ -439,7 +439,8 @@ retry:      /* transaction retry */
        }
 
        ltid = NULL;
-       op->o_private = NULL;
+       LDAP_SLIST_REMOVE( &op->o_extra, &opinfo.boi_oe, OpExtra, oe_next );
+       opinfo.boi_oe.oe_key = NULL;
 
        if ( rs->sr_err != LDAP_SUCCESS ) {
                Debug( LDAP_DEBUG_TRACE,
@@ -465,7 +466,9 @@ return_results:
        if( ltid != NULL ) {
                TXN_ABORT( ltid );
        }
-       op->o_private = NULL;
+       if ( opinfo.boi_oe.oe_key ) {
+               LDAP_SLIST_REMOVE( &op->o_extra, &opinfo.boi_oe, OpExtra, oe_next );
+       }
 
        if( success == LDAP_SUCCESS ) {
                /* We own the entry now, and it can be purged at will
index 7368847749c1603c22fcf72d513c3317a3d6d2e6..2d0109fccd290ec48365637918fef339dde4803d 100644 (file)
@@ -267,7 +267,7 @@ struct bdb_lock_info {
 };
 
 struct bdb_op_info {
-       BackendDB*      boi_bdb;
+       OpExtra boi_oe;
        DB_TXN*         boi_txn;
        u_int32_t       boi_err;
        int             boi_acl_cache;
index f0ad3d217bbc923350fb4c4385ca325053f70c47..edf73ab28ca7d69416d446db99df3fa718a28552 100644 (file)
@@ -925,7 +925,7 @@ load1:
                                                if (( flag & ID_NOCACHE ) &&
                                                        ( bdb_cache_entryinfo_trylock( *eip ) == 0 )) {
                                                        /* Set the cached state only if no other thread
-                                                        * found the info while we was loading the entry.
+                                                        * found the info while we were loading the entry.
                                                         */
                                                        if ( (*eip)->bei_finders == 1 )
                                                                (*eip)->bei_state |= CACHE_ENTRY_NOT_CACHED;
@@ -1292,7 +1292,7 @@ bdb_cache_delete_cleanup(
        Cache *cache,
        EntryInfo *ei )
 {
-       bdb_cache_entryinfo_lock( ei );
+       /* Enter with ei locked */
 
        if ( ei->bei_e ) {
                ei->bei_e->e_private = NULL;
index dfa50bed0a638fdf007d94823ebc39fcef1c7399..6f0207f6e616ab2873e3e2a694f35886c6982300 100644 (file)
@@ -124,7 +124,8 @@ retry:      /* transaction retry */
                        0, 0, 0 );
                rs->sr_err = TXN_ABORT( ltid );
                ltid = NULL;
-               op->o_private = NULL;
+               LDAP_SLIST_REMOVE( &op->o_extra, &opinfo.boi_oe, OpExtra, oe_next );
+               opinfo.boi_oe.oe_key = NULL;
                op->o_do_not_cache = opinfo.boi_acl_cache;
                if( rs->sr_err != 0 ) {
                        rs->sr_err = LDAP_OTHER;
@@ -155,11 +156,11 @@ retry:    /* transaction retry */
 
        locker = TXN_ID ( ltid );
 
-       opinfo.boi_bdb = op->o_bd;
+       opinfo.boi_oe.oe_key = bdb;
        opinfo.boi_txn = ltid;
        opinfo.boi_err = 0;
        opinfo.boi_acl_cache = op->o_do_not_cache;
-       op->o_private = &opinfo;
+       LDAP_SLIST_INSERT_HEAD( &op->o_extra, &opinfo.boi_oe, oe_next );
 
        if ( !be_issuffix( op->o_bd, &op->o_req_ndn ) ) {
                dnParent( &op->o_req_ndn, &pdn );
@@ -536,7 +537,8 @@ retry:      /* transaction retry */
                rs->sr_err = TXN_COMMIT( ltid, 0 );
        }
        ltid = NULL;
-       op->o_private = NULL;
+       LDAP_SLIST_REMOVE( &op->o_extra, &opinfo.boi_oe, OpExtra, oe_next );
+       opinfo.boi_oe.oe_key = NULL;
 
        BDB_LOG_PRINTF( bdb->bi_dbenv, NULL, "slapd Committed delete %s(%d)",
                e->e_nname.bv_val, e->e_id );
@@ -572,6 +574,7 @@ return_results:
        if( e != NULL ) {
                if ( rs->sr_err == LDAP_SUCCESS ) {
                        /* Free the EntryInfo and the Entry */
+                       bdb_cache_entryinfo_lock( BEI(e) );
                        bdb_cache_delete_cleanup( &bdb->bi_cache, BEI(e) );
                } else {
                        bdb_unlocked_cache_return_entry_w(&bdb->bi_cache, e);
@@ -581,7 +584,9 @@ return_results:
        if( ltid != NULL ) {
                TXN_ABORT( ltid );
        }
-       op->o_private = NULL;
+       if ( opinfo.boi_oe.oe_key ) {
+               LDAP_SLIST_REMOVE( &op->o_extra, &opinfo.boi_oe, OpExtra, oe_next );
+       }
 
        send_ldap_result( op, rs );
        slap_graduate_commit_csn( op );
index ee612722759e87af3fa8cf0694856dddc5c3fabf..15da6c76594732a4529d224aea5afc529d75f8d1 100644 (file)
@@ -242,7 +242,8 @@ int bdb_entry_release(
        int rw )
 {
        struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
-       struct bdb_op_info *boi = NULL;
+       struct bdb_op_info *boi;
+       OpExtra *oex;
  
        /* slapMode : SLAP_SERVER_MODE, SLAP_TOOL_MODE,
                        SLAP_TRUNCATE_MODE, SLAP_UNDEFINED_MODE */
@@ -257,7 +258,10 @@ int bdb_entry_release(
 #endif
                }
                /* free entry and reader or writer lock */
-               boi = (struct bdb_op_info *)op->o_private;
+               LDAP_SLIST_FOREACH( oex, &op->o_extra, oe_next ) {
+                       if ( oex->oe_key == bdb ) break;
+               }
+               boi = (struct bdb_op_info *)oex;
 
                /* lock is freed with txn */
                if ( !boi || boi->boi_txn ) {
@@ -274,8 +278,8 @@ int bdb_entry_release(
                                }
                        }
                        if ( !boi->boi_locks ) {
+                               LDAP_SLIST_REMOVE( &op->o_extra, &boi->boi_oe, OpExtra, oe_next );
                                op->o_tmpfree( boi, op->o_tmpmemctx );
-                               op->o_private = NULL;
                        }
                }
        } else {
@@ -328,9 +332,14 @@ int bdb_entry_get(
                "=> bdb_entry_get: oc: \"%s\", at: \"%s\"\n",
                oc ? oc->soc_cname.bv_val : "(null)", at_name, 0);
 
-       if( op ) boi = (struct bdb_op_info *) op->o_private;
-       if( boi != NULL && op->o_bd->be_private == boi->boi_bdb->be_private ) {
-               txn = boi->boi_txn;
+       if( op ) {
+               OpExtra *oex;
+               LDAP_SLIST_FOREACH( oex, &op->o_extra, oe_next ) {
+                       if ( oex->oe_key == bdb ) break;
+               }
+               boi = (struct bdb_op_info *)oex;
+               if ( boi )
+                       txn = boi->boi_txn;
        }
 
        if ( txn != NULL ) {
@@ -407,8 +416,8 @@ return_results:
                        if ( op ) {
                                if ( !boi ) {
                                        boi = op->o_tmpcalloc(1,sizeof(struct bdb_op_info),op->o_tmpmemctx);
-                                       boi->boi_bdb = op->o_bd;
-                                       op->o_private = boi;
+                                       boi->boi_oe.oe_key = bdb;
+                                       LDAP_SLIST_INSERT_HEAD( &op->o_extra, &boi->boi_oe, oe_next );
                                }
                                if ( !boi->boi_txn ) {
                                        struct bdb_lock_info *bli;
index 8e63506598e3f67f1038b11d9554a70cd3715371..67d04d95f3c4e6cbd14485636b95c7ae2333ae58 100644 (file)
@@ -410,7 +410,8 @@ retry:      /* transaction retry */
 
                rs->sr_err = TXN_ABORT( ltid );
                ltid = NULL;
-               op->o_private = NULL;
+               LDAP_SLIST_REMOVE( &op->o_extra, &opinfo.boi_oe, OpExtra, oe_next );
+               opinfo.boi_oe.oe_key = NULL;
                op->o_do_not_cache = opinfo.boi_acl_cache;
                if( rs->sr_err != 0 ) {
                        rs->sr_err = LDAP_OTHER;
@@ -439,11 +440,11 @@ retry:    /* transaction retry */
 
        locker = TXN_ID ( ltid );
 
-       opinfo.boi_bdb = op->o_bd;
+       opinfo.boi_oe.oe_key = bdb;
        opinfo.boi_txn = ltid;
        opinfo.boi_err = 0;
        opinfo.boi_acl_cache = op->o_do_not_cache;
-       op->o_private = &opinfo;
+       LDAP_SLIST_INSERT_HEAD( &op->o_extra, &opinfo.boi_oe, oe_next );
 
        /* get entry or ancestor */
        rs->sr_err = bdb_dn2entry( op, ltid, &op->o_req_ndn, &ei, 1,
@@ -666,7 +667,8 @@ retry:      /* transaction retry */
                rs->sr_err = TXN_COMMIT( ltid, 0 );
        }
        ltid = NULL;
-       op->o_private = NULL;
+       LDAP_SLIST_REMOVE( &op->o_extra, &opinfo.boi_oe, OpExtra, oe_next );
+       opinfo.boi_oe.oe_key = NULL;
 
        if( rs->sr_err != 0 ) {
                Debug( LDAP_DEBUG_TRACE,
@@ -705,7 +707,9 @@ done:
        if( ltid != NULL ) {
                TXN_ABORT( ltid );
        }
-       op->o_private = NULL;
+       if ( opinfo.boi_oe.oe_key ) {
+               LDAP_SLIST_REMOVE( &op->o_extra, &opinfo.boi_oe, OpExtra, oe_next );
+       }
 
        if( e != NULL ) {
                bdb_unlocked_cache_return_entry_w (&bdb->bi_cache, e);
index 117cb05c25b2d0b939799a98b2c21e8930f1104c..fbe9f2ea20f2c9f2dc01022490ae381c44afd3aa 100644 (file)
@@ -134,7 +134,8 @@ retry:      /* transaction retry */
 
                rs->sr_err = TXN_ABORT( ltid );
                ltid = NULL;
-               op->o_private = NULL;
+               LDAP_SLIST_REMOVE( &op->o_extra, &opinfo.boi_oe, OpExtra, oe_next );
+               opinfo.boi_oe.oe_key = NULL;
                op->o_do_not_cache = opinfo.boi_acl_cache;
                if( rs->sr_err != 0 ) {
                        rs->sr_err = LDAP_OTHER;
@@ -165,11 +166,11 @@ retry:    /* transaction retry */
 
        locker = TXN_ID ( ltid );
 
-       opinfo.boi_bdb = op->o_bd;
+       opinfo.boi_oe.oe_key = bdb;
        opinfo.boi_txn = ltid;
        opinfo.boi_err = 0;
        opinfo.boi_acl_cache = op->o_do_not_cache;
-       op->o_private = &opinfo;
+       LDAP_SLIST_INSERT_HEAD( &op->o_extra, &opinfo.boi_oe, oe_next );
 
        /* get entry */
        rs->sr_err = bdb_dn2entry( op, ltid, &op->o_req_ndn, &ei, 1,
@@ -764,7 +765,8 @@ retry:      /* transaction retry */
        }
  
        ltid = NULL;
-       op->o_private = NULL;
+       LDAP_SLIST_REMOVE( &op->o_extra, &opinfo.boi_oe, OpExtra, oe_next );
+       opinfo.boi_oe.oe_key = NULL;
  
        if( rs->sr_err != LDAP_SUCCESS ) {
                Debug( LDAP_DEBUG_TRACE,
@@ -823,7 +825,9 @@ done:
        if( ltid != NULL ) {
                TXN_ABORT( ltid );
        }
-       op->o_private = NULL;
+       if ( opinfo.boi_oe.oe_key ) {
+               LDAP_SLIST_REMOVE( &op->o_extra, &opinfo.boi_oe, OpExtra, oe_next );
+       }
 
        if( preread_ctrl != NULL && (*preread_ctrl) != NULL ) {
                slap_sl_free( (*preread_ctrl)->ldctl_value.bv_val, op->o_tmpmemctx );
index 3bbe0a7abcfd7185c801a114088f88d32378ff59..448316516fee90db5cf019023df8aca24c47780e 100644 (file)
@@ -322,11 +322,16 @@ bdb_search( Operation *op, SlapReply *rs )
        DB_LOCK         lock;
        struct  bdb_op_info     *opinfo = NULL;
        DB_TXN                  *ltid = NULL;
+       OpExtra *oex;
 
        Debug( LDAP_DEBUG_TRACE, "=> " LDAP_XSTRING(bdb_search) "\n", 0, 0, 0);
        attrs = op->oq_search.rs_attrs;
 
-       opinfo = (struct bdb_op_info *) op->o_private;
+       LDAP_SLIST_FOREACH( oex, &op->o_extra, oe_next ) {
+               if ( oex->oe_key == bdb )
+                       break;
+       }
+       opinfo = (struct bdb_op_info *) oex;
 
        manageDSAit = get_manageDSAit( op );