rc = mdb_txn_begin( mdb->mi_dbenv, 0, &txn );
if ( rc )
break;
+ rc = mdb_cursor_open( txn, mdb->mi_id2entry, &curs );
+ if ( rc ) {
+ mdb_txn_abort( txn );
+ break;
+ }
if ( getnext ) {
getnext = 0;
- rc = mdb_cursor_open( txn, mdb->mi_id2entry, &curs );
- if ( rc ) {
- mdb_txn_abort( txn );
- break;
- }
rc = mdb_cursor_get( curs, &key, &data, MDB_SET_RANGE );
- memcpy( &id, key.mv_data, sizeof( id ));
- mdb_cursor_close( curs );
if ( rc ) {
mdb_txn_abort( txn );
if ( rc == MDB_NOTFOUND )
rc = 0;
break;
}
+ memcpy( &id, key.mv_data, sizeof( id ));
}
- rc = mdb_id2entry( op, txn, id, &e );
+ rc = mdb_id2entry( op, curs, id, &e );
+ mdb_cursor_close( curs );
if ( rc ) {
mdb_txn_abort( txn );
if ( rc == MDB_NOTFOUND ) {
Entry **e,
int matched )
{
+ struct mdb_info *mdb = (struct mdb_info *) op->o_bd->be_private;
int rc, rc2;
ID id = NOID;
struct berval mbv, nmbv;
+ MDB_cursor *mc;
Debug(LDAP_DEBUG_TRACE, "mdb_dn2entry(\"%s\")\n",
dn->bv_val, 0, 0 );
rc = mdb_dn2id( op, tid, dn, &id, &mbv, &nmbv );
if ( rc ) {
- if ( matched )
- rc2 = mdb_id2entry( op, tid, id, e );
+ if ( matched ) {
+ rc2 = mdb_cursor_open( tid, mdb->mi_id2entry, &mc );
+ if ( rc2 == MDB_SUCCESS ) {
+ rc2 = mdb_id2entry( op, mc, id, e );
+ mdb_cursor_close( mc );
+ }
+ }
} else {
- rc = mdb_id2entry( op, tid, id, e );
+ rc = mdb_cursor_open( tid, mdb->mi_id2entry, &mc );
+ if ( rc == MDB_SUCCESS ) {
+ rc = mdb_id2entry( op, mc, id, e );
+ mdb_cursor_close(mc);
+ }
}
if ( *e ) {
(*e)->e_name = mbv;
SlapReply *rs,
Entry *e,
MDB_txn *txn,
+ MDB_cursor *mci,
ID *ids,
ID *scopes );
SlapReply *rs,
Entry *e,
MDB_txn *txn,
+ MDB_cursor *mci,
ID *scopes,
ID *stack )
{
for (ida = mdb_idl_first(curscop, &cursora); ida != NOID;
ida = mdb_idl_next(curscop, &cursora))
{
- rs->sr_err = mdb_id2entry(op, txn, ida, &a);
+ rs->sr_err = mdb_id2entry(op, mci, ida, &a);
if (rs->sr_err != LDAP_SUCCESS) {
continue;
}
* be found, ignore it and move on. This should never happen;
* we should never see the ID of an entry that doesn't exist.
*/
- rs->sr_err = mdb_id2entry(op, txn, ido, &e);
+ rs->sr_err = mdb_id2entry(op, mci, ido, &e);
if ( rs->sr_err != LDAP_SUCCESS ) {
goto nextido;
}
* a range and simple iteration hits missing entryIDs
*/
static int
-mdb_get_nextid(struct mdb_info *mdb, MDB_txn *txn, ID *cursor)
+mdb_get_nextid(MDB_cursor *mci, ID *cursor)
{
- MDB_cursor *curs;
MDB_val key;
ID id;
int rc;
id = *cursor + 1;
- rc = mdb_cursor_open( txn, mdb->mi_id2entry, &curs );
- if ( rc )
- return rc;
key.mv_data = &id;
key.mv_size = sizeof(ID);
- rc = mdb_cursor_get( curs, &key, NULL, MDB_SET_RANGE );
- mdb_cursor_close( curs );
+ rc = mdb_cursor_get( mci, &key, NULL, MDB_SET_RANGE );
if ( rc )
return rc;
memcpy( cursor, key.mv_data, sizeof(ID));
int manageDSAit;
int tentries = 0;
IdScopes isc;
+ MDB_cursor *mci;
mdb_op_info opinfo = {0}, *moi = &opinfo;
MDB_txn *ltid = NULL;
isc.mc = NULL;
isc.scopes = scopes;
+ rs->sr_err = mdb_cursor_open( ltid, mdb->mi_id2entry, &mci );
+ if ( rs->sr_err ) {
+ send_ldap_error( op, rs, LDAP_OTHER, "internal error" );
+ goto done;
+ }
+
if ( op->ors_deref & LDAP_DEREF_FINDING ) {
MDB_IDL_ZERO(candidates);
}
MDB_IDL_ZERO( scopes );
mdb_idl_insert( scopes, base->e_id );
rs->sr_err = search_candidates( op, rs, base,
- ltid, candidates, scopes );
+ ltid, mci, candidates, scopes );
}
/* start cursor at beginning of candidates.
} else {
/* get the entry */
- rs->sr_err = mdb_id2entry( op, ltid, id, &e );
+ rs->sr_err = mdb_id2entry( op, mci, id, &e );
if (rs->sr_err == LDAP_BUSY) {
rs->sr_text = "ldap server busy";
(long) id, 0, 0 );
} else {
/* get the next ID from the DB */
- rs->sr_err = mdb_get_nextid( mdb, ltid, &cursor );
+ rs->sr_err = mdb_get_nextid( mci, &cursor );
if ( rs->sr_err == MDB_NOTFOUND ) {
break;
}
SlapReply *rs,
Entry *e,
MDB_txn *txn,
+ MDB_cursor *mci,
ID *ids,
ID *scopes )
{
}
if( op->ors_deref & LDAP_DEREF_SEARCHING ) {
- rc = search_aliases( op, rs, e, txn, scopes, stack );
+ rc = search_aliases( op, rs, e, txn, mci, scopes, stack );
} else {
rc = LDAP_SUCCESS;
}