Commit 6ac8a0c5 authored by Howard Chu's avatar Howard Chu
Browse files

ITS#5262 use explicit cursor and locker in dn2id

parent eda5b4d0
......@@ -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 ) {
......
......@@ -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
......
......@@ -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;
......
......@@ -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 ) {
......
......@@ -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:
......
......@@ -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
);
......
......@@ -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 ) ) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment