]> git.sur5r.net Git - openldap/commitdiff
ITS#5262 use explicit cursor and locker in dn2id
authorHoward Chu <hyc@openldap.org>
Wed, 5 Dec 2007 14:09:34 +0000 (14:09 +0000)
committerHoward Chu <hyc@openldap.org>
Wed, 5 Dec 2007 14:09:34 +0000 (14:09 +0000)
servers/slapd/back-bdb/cache.c
servers/slapd/back-bdb/dn2entry.c
servers/slapd/back-bdb/dn2id.c
servers/slapd/back-bdb/filterindex.c
servers/slapd/back-bdb/modrdn.c
servers/slapd/back-bdb/proto-bdb.h
servers/slapd/back-bdb/tools.c

index 7cd7194ab7c407b04b7a27c5d338eb72e729de51..6215142435b4bf9430abf7b5a3169ba2089986df 100644 (file)
@@ -380,7 +380,7 @@ bdb_entryinfo_add_internal(
 int
 bdb_cache_find_ndn(
        Operation       *op,
-       DB_TXN          *txn,
+       BDB_LOCKER              locker,
        struct berval   *ndn,
        EntryInfo       **res )
 {
@@ -429,7 +429,7 @@ bdb_cache_find_ndn(
                                (ei.bei_nrdn.bv_val - ndn->bv_val);
                        bdb_cache_entryinfo_unlock( eip );
 
-                       rc = bdb_dn2id( op, txn, &ei.bei_nrdn, &ei );
+                       rc = bdb_dn2id( op, locker, &ei.bei_nrdn, &ei );
                        if (rc) {
                                bdb_cache_entryinfo_lock( eip );
                                *res = eip;
@@ -821,7 +821,7 @@ again:      ldap_pvt_thread_rdwr_rlock( &bdb->bi_cache.c_rwlock );
 #ifndef BDB_HIER
                rc = bdb_id2entry( op->o_bd, tid, locker, id, &ep );
                if ( rc == 0 ) {
-                       rc = bdb_cache_find_ndn( op, tid,
+                       rc = bdb_cache_find_ndn( op, locker,
                                &ep->e_nname, eip );
                        if ( *eip ) flag |= ID_LOCKED;
                        if ( rc ) {
index e897cbef262d540a3195bf8c2ccbda35d472e2e0..e79562f5faa672b7640c0b77bd4b669bbfc7396e 100644 (file)
@@ -45,7 +45,7 @@ bdb_dn2entry(
 
        *e = NULL;
 
-       rc = bdb_cache_find_ndn( op, tid, dn, &ei );
+       rc = bdb_cache_find_ndn( op, locker, dn, &ei );
        if ( rc ) {
                if ( matched && rc == DB_NOTFOUND ) {
                        /* Set the return value, whether we have its entry
index 3f83cf4fc6944799f0db63f575c2898f4976e852..7dbe325c044e7971f6138eed7c00c00b9a6d9b7e 100644 (file)
@@ -244,12 +244,13 @@ done:
 int
 bdb_dn2id(
        Operation *op,
-       DB_TXN *txn,
+       BDB_LOCKER locker,
        struct berval   *dn,
        EntryInfo *ei )
 {
        struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
        DB *db = bdb->bi_dn2id->bdi_db;
+       DBC     *cursor;
        int             rc;
        DBT             key, data;
        ID              nid;
@@ -267,8 +268,14 @@ bdb_dn2id(
        data.ulen = sizeof(ID);
        data.flags = DB_DBT_USERMEM;
 
+       rc = db->cursor( db, NULL, &cursor, bdb->bi_db_opflags );
+       if ( rc ) return rc;
+       if ( locker ) {
+               CURSOR_SETLOCKER(cursor, locker);
+       }
+
        /* fetch it */
-       rc = db->get( db, txn, &key, &data, bdb->bi_db_opflags );
+       rc = cursor->c_get( cursor, &key, &data, DB_SET );
 
        if( rc != 0 ) {
                Debug( LDAP_DEBUG_TRACE, "<= bdb_dn2id: get failed: %s (%d)\n",
@@ -279,6 +286,7 @@ bdb_dn2id(
                        ei->bei_id, 0, 0 );
        }
 
+       cursor->c_close( cursor );
        op->o_tmpfree( key.data, op->o_tmpmemctx );
        return rc;
 }
@@ -638,7 +646,7 @@ hdb_dn2id_delete(
 int
 hdb_dn2id(
        Operation       *op,
-       DB_TXN *txn,
+       BDB_LOCKER locker,
        struct berval   *in,
        EntryInfo       *ei )
 {
@@ -669,8 +677,11 @@ hdb_dn2id(
        data.dlen = data.ulen;
        data.flags = DB_DBT_USERMEM | DB_DBT_PARTIAL;
 
-       rc = db->cursor( db, txn, &cursor, bdb->bi_db_opflags );
+       rc = db->cursor( db, NULL, &cursor, bdb->bi_db_opflags );
        if ( rc ) return rc;
+       if ( locker ) {
+               CURSOR_SETLOCKER( cursor, locker );
+       }
 
        d = op->o_tmpalloc( data.size * 3, op->o_tmpmemctx );
        d->nrdnlen[1] = nrlen & 0xff;
index 0e4983f0fc83387f1c5249aa7581ae025ea146fd..d5a3108d8f59fea2622560960f26aea141c732b4 100644 (file)
@@ -504,7 +504,7 @@ ext_candidates(
                BDB_IDL_ZERO( ids );
                if ( mra->ma_rule == slap_schema.si_mr_distinguishedNameMatch ) {
                        ei = NULL;
-                       rc = bdb_cache_find_ndn( op, NULL, &mra->ma_value, &ei );
+                       rc = bdb_cache_find_ndn( op, locker, &mra->ma_value, &ei );
                        if ( rc == LDAP_SUCCESS )
                                bdb_idl_insert( ids, ei->bei_id );
                        if ( ei )
@@ -518,7 +518,7 @@ ext_candidates(
                                struct berval pdn;
                                ei = NULL;
                                dnParent( &mra->ma_value, &pdn );
-                               bdb_cache_find_ndn( op, NULL, &pdn, &ei );
+                               bdb_cache_find_ndn( op, locker, &pdn, &ei );
                                if ( ei ) {
                                        bdb_cache_entryinfo_unlock( ei );
                                        while ( ei && ei->bei_id ) {
@@ -538,7 +538,7 @@ ext_candidates(
                                scope = LDAP_SCOPE_BASE;
                        if ( scope > LDAP_SCOPE_BASE ) {
                                ei = NULL;
-                               rc = bdb_cache_find_ndn( op, NULL, &mra->ma_value, &ei );
+                               rc = bdb_cache_find_ndn( op, locker, &mra->ma_value, &ei );
                                if ( ei )
                                        bdb_cache_entryinfo_unlock( ei );
                                if ( rc == LDAP_SUCCESS ) {
index ffb2a3a8911e0572b312092fcfa5d7f2e63523e0..9fa9f33d62949dadb0a037866ebef33efef51ec2 100644 (file)
@@ -551,7 +551,7 @@ retry:      /* transaction retry */
 
        /* Shortcut the search */
        nei = neip ? neip : eip;
-       rs->sr_err = bdb_cache_find_ndn ( op, ltid, &new_ndn, &nei );
+       rs->sr_err = bdb_cache_find_ndn ( op, locker, &new_ndn, &nei );
        if ( nei ) bdb_cache_entryinfo_unlock( nei );
        switch( rs->sr_err ) {
        case DB_LOCK_DEADLOCK:
index 779f100a93b3968849b9506aecb0edf70f6738b7..27de00c59b07d081fb693cfcaab313472c334ce6 100644 (file)
@@ -97,7 +97,7 @@ int bdb_dn2entry LDAP_P(( Operation *op, DB_TXN *tid,
 
 int bdb_dn2id(
        Operation *op,
-       DB_TXN *tid,
+       BDB_LOCKER locker,
        struct berval *dn,
        EntryInfo *ei );
 
@@ -529,7 +529,7 @@ int bdb_cache_modify(
 );
 int bdb_cache_find_ndn(
        Operation *op,
-       DB_TXN  *txn,
+       BDB_LOCKER      locker,
        struct berval   *ndn,
        EntryInfo       **res
 );
index e971d9080ac757261b844d891ccf444b1649eb26..ff9d3199b0f5e4390a9b7607444bb7442cc6f122 100644 (file)
@@ -231,7 +231,7 @@ ID bdb_tool_dn2id_get(
        op.o_tmpmemctx = NULL;
        op.o_tmpmfuncs = &ch_mfuncs;
 
-       rc = bdb_cache_find_ndn( &op, NULL, dn, &ei );
+       rc = bdb_cache_find_ndn( &op, 0, dn, &ei );
        if ( ei ) bdb_cache_entryinfo_unlock( ei );
        if ( rc == DB_NOTFOUND )
                return NOID;
@@ -340,7 +340,7 @@ static int bdb_tool_next_id(
                return 0;
        }
 
-       rc = bdb_cache_find_ndn( op, tid, &ndn, &ei );
+       rc = bdb_cache_find_ndn( op, TXN_ID( tid ), &ndn, &ei );
        if ( ei ) bdb_cache_entryinfo_unlock( ei );
        if ( rc == DB_NOTFOUND ) {
                if ( !be_issuffix( op->o_bd, &ndn ) ) {