From: Howard Chu Date: Wed, 5 Dec 2007 14:09:34 +0000 (+0000) Subject: ITS#5262 use explicit cursor and locker in dn2id X-Git-Tag: OPENLDAP_REL_ENG_2_4_9~20^2~355 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=6ac8a0c584d2ee360fdc18a3b09559a8eb8012fb;p=openldap ITS#5262 use explicit cursor and locker in dn2id --- diff --git a/servers/slapd/back-bdb/cache.c b/servers/slapd/back-bdb/cache.c index 7cd7194ab7..6215142435 100644 --- a/servers/slapd/back-bdb/cache.c +++ b/servers/slapd/back-bdb/cache.c @@ -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 ) { diff --git a/servers/slapd/back-bdb/dn2entry.c b/servers/slapd/back-bdb/dn2entry.c index e897cbef26..e79562f5fa 100644 --- a/servers/slapd/back-bdb/dn2entry.c +++ b/servers/slapd/back-bdb/dn2entry.c @@ -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 diff --git a/servers/slapd/back-bdb/dn2id.c b/servers/slapd/back-bdb/dn2id.c index 3f83cf4fc6..7dbe325c04 100644 --- a/servers/slapd/back-bdb/dn2id.c +++ b/servers/slapd/back-bdb/dn2id.c @@ -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; diff --git a/servers/slapd/back-bdb/filterindex.c b/servers/slapd/back-bdb/filterindex.c index 0e4983f0fc..d5a3108d8f 100644 --- a/servers/slapd/back-bdb/filterindex.c +++ b/servers/slapd/back-bdb/filterindex.c @@ -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 ) { diff --git a/servers/slapd/back-bdb/modrdn.c b/servers/slapd/back-bdb/modrdn.c index ffb2a3a891..9fa9f33d62 100644 --- a/servers/slapd/back-bdb/modrdn.c +++ b/servers/slapd/back-bdb/modrdn.c @@ -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: diff --git a/servers/slapd/back-bdb/proto-bdb.h b/servers/slapd/back-bdb/proto-bdb.h index 779f100a93..27de00c59b 100644 --- a/servers/slapd/back-bdb/proto-bdb.h +++ b/servers/slapd/back-bdb/proto-bdb.h @@ -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 ); diff --git a/servers/slapd/back-bdb/tools.c b/servers/slapd/back-bdb/tools.c index e971d9080a..ff9d3199b0 100644 --- a/servers/slapd/back-bdb/tools.c +++ b/servers/slapd/back-bdb/tools.c @@ -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 ) ) {