of #ifdef USE_SL_MALLOC...
}
/* get entry or parent */
- rs->sr_err = bdb_dn2entry( op->o_bd, ltid, &op->ora_e->e_nname, &ei,
- 1, locker, &lock, op->o_tmpmemctx );
+ rs->sr_err = bdb_dn2entry( op, ltid, &op->ora_e->e_nname, &ei,
+ 1, locker, &lock );
switch( rs->sr_err ) {
case 0:
rs->sr_err = LDAP_ALREADY_EXISTS;
}
/* dn2id index */
- rs->sr_err = bdb_dn2id_add( op->o_bd, lt2, ei, op->oq_add.rs_e,
- op->o_tmpmemctx );
+ rs->sr_err = bdb_dn2id_add( op, lt2, ei, op->oq_add.rs_e );
if ( rs->sr_err != 0 ) {
#ifdef NEW_LOGGING
LDAP_LOG ( OPERATION, ERR,
dn2entry_retry:
/* get entry with reader lock */
- rs->sr_err = bdb_dn2entry( op->o_bd, NULL, &op->o_req_ndn, &ei, 1,
- locker, &lock, op->o_tmpmemctx );
+ rs->sr_err = bdb_dn2entry( op, NULL, &op->o_req_ndn, &ei, 1,
+ locker, &lock );
switch(rs->sr_err) {
case DB_NOTFOUND:
*/
int
bdb_cache_find_ndn(
- Backend *be,
+ Operation *op,
DB_TXN *txn,
struct berval *ndn,
EntryInfo **res,
- u_int32_t locker,
- void *ctx
+ u_int32_t locker
)
{
- struct bdb_info *bdb = (struct bdb_info *) be->be_private;
+ struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
EntryInfo ei, *eip, *ei2;
int rc = 0;
char *ptr;
if ( *res ) {
/* we're doing a onelevel search for an RDN */
ei.bei_nrdn.bv_val = ndn->bv_val;
- ei.bei_nrdn.bv_len = dn_rdnlen( be, ndn );
+ ei.bei_nrdn.bv_len = dn_rdnlen( op->o_bd, ndn );
eip = *res;
} else {
/* we're searching a full DN from the root */
- ptr = ndn->bv_val + ndn->bv_len - be->be_nsuffix[0].bv_len;
+ ptr = ndn->bv_val + ndn->bv_len - op->o_bd->be_nsuffix[0].bv_len;
ei.bei_nrdn.bv_val = ptr;
- ei.bei_nrdn.bv_len = be->be_nsuffix[0].bv_len;
+ ei.bei_nrdn.bv_len = op->o_bd->be_nsuffix[0].bv_len;
eip = &bdb->bi_cache.c_dntree;
}
ei.bei_nrdn.bv_len = ndn->bv_len - (ei.bei_nrdn.bv_val - ndn->bv_val);
bdb_cache_entryinfo_unlock( eip );
- rc = bdb_dn2id( be, txn, &ei.bei_nrdn, &ei, ctx );
+ rc = bdb_dn2id( op, txn, &ei.bei_nrdn, &ei );
if (rc) {
bdb_cache_entryinfo_lock( eip );
*res = eip;
* been linked into the cache.
*/
static int
-bdb_cache_find_parent(
- Backend *be,
+hdb_cache_find_parent(
+ Operation *op,
DB_TXN *txn,
ID id,
- EntryInfo **res,
- void *ctx
+ EntryInfo **res
)
{
- struct bdb_info *bdb = (struct bdb_info *) be->be_private;
+ struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
EntryInfo ei, eip, *ei2 = NULL, *ein = NULL, *eir = NULL;
ID parent;
int rc;
ei.bei_kids = NULL;
for (;;) {
- rc = bdb_dn2id_parent( be, txn, &ei, &eip.bei_id, ctx );
+ rc = hdb_dn2id_parent( op, txn, &ei, &eip.bei_id );
if ( rc ) break;
/* Save the previous node, if any */
int
bdb_cache_find_id(
- Backend *be,
+ Operation *op,
DB_TXN *tid,
ID id,
EntryInfo **eip,
int islocked,
u_int32_t locker,
- DB_LOCK *lock,
- void *ctx
+ DB_LOCK *lock
)
{
- struct bdb_info *bdb = (struct bdb_info *) be->be_private;
+ struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
Entry *ep = NULL;
int rc = 0;
EntryInfo ei;
/* See if the ID exists in the database; add it to the cache if so */
if ( !*eip ) {
#ifndef BDB_HIER
- rc = bdb_id2entry( be, tid, id, &ep );
+ rc = bdb_id2entry( op->o_bd, tid, id, &ep );
if ( rc == 0 ) {
- rc = bdb_cache_find_ndn( be, tid,
- &ep->e_nname, eip, locker, ctx );
+ rc = bdb_cache_find_ndn( op, tid,
+ &ep->e_nname, eip, locker );
if ( *eip )
islocked = 1;
if ( rc ) {
}
}
#else
- rc = bdb_cache_find_parent(be, tid, id, eip, ctx );
+ rc = hdb_cache_find_parent(op, tid, id, eip );
if ( rc == 0 && *eip )
islocked = 1;
#endif
rc = DB_NOTFOUND;
} else if (!(*eip)->bei_e ) {
if (!ep) {
- rc = bdb_id2entry( be, tid, id, &ep );
+ rc = bdb_id2entry( op->o_bd, tid, id, &ep );
}
if ( rc == 0 ) {
bdb_cache_entry_db_lock( bdb->bi_dbenv, locker,
dn2entry_retry:
/* get entry */
- rs->sr_err = bdb_dn2entry( op->o_bd, NULL, &op->o_req_ndn, &ei, 1, locker, &lock, op->o_tmpmemctx );
+ rs->sr_err = bdb_dn2entry( op, NULL, &op->o_req_ndn, &ei, 1, locker, &lock );
switch( rs->sr_err ) {
case DB_NOTFOUND:
}
/* get entry */
- rs->sr_err = bdb_dn2entry( op->o_bd, ltid, &op->o_req_ndn, &ei, 1,
- locker, &lock, op->o_tmpmemctx );
+ rs->sr_err = bdb_dn2entry( op, ltid, &op->o_req_ndn, &ei, 1,
+ locker, &lock );
switch( rs->sr_err ) {
case 0:
if ( rs->sr_err == 0 ) {
e = ei->bei_e;
eip = ei->bei_parent;
- bdb_cache_find_id( op->o_bd, ltid, eip->bei_id, &eip,
- 0, locker, &plock, op->o_tmpmemctx );
+ bdb_cache_find_id( op, ltid, eip->bei_id, &eip,
+ 0, locker, &plock );
} else {
matched = ei->bei_e;
}
}
/* delete from dn2id */
- rs->sr_err = bdb_dn2id_delete( op->o_bd, lt2, eip, e,
- op->o_tmpmemctx );
+ rs->sr_err = bdb_dn2id_delete( op, lt2, eip, e );
if ( rs->sr_err != 0 ) {
#ifdef NEW_LOGGING
LDAP_LOG ( OPERATION, ERR,
int
bdb_dn2entry(
- BackendDB *be,
+ Operation *op,
DB_TXN *tid,
struct berval *dn,
EntryInfo **e,
int matched,
u_int32_t locker,
- DB_LOCK *lock,
- void *ctx )
+ DB_LOCK *lock )
{
EntryInfo *ei = NULL;
int rc;
*e = NULL;
- rc = bdb_cache_find_ndn( be, tid, dn, &ei, locker, ctx );
+ rc = bdb_cache_find_ndn( op, tid, dn, &ei, locker );
if ( rc ) {
if ( matched && rc == DB_NOTFOUND ) {
/* Set the return value, whether we have its entry
*/
*e = ei;
if ( ei && ei->bei_id )
- bdb_cache_find_id( be, tid, ei->bei_id,
- &ei, 1, locker, lock, ctx );
+ bdb_cache_find_id( op, tid, ei->bei_id,
+ &ei, 1, locker, lock );
else if ( ei )
bdb_cache_entryinfo_unlock( ei );
} else if ( ei ) {
bdb_cache_entryinfo_unlock( ei );
}
} else {
- rc = bdb_cache_find_id( be, tid, ei->bei_id, &ei, 1,
- locker, lock, ctx );
+ rc = bdb_cache_find_id( op, tid, ei->bei_id, &ei, 1,
+ locker, lock );
if ( rc == 0 ) {
*e = ei;
} else if ( matched && rc == DB_NOTFOUND ) {
/* always return EntryInfo */
ei = ei->bei_parent;
- bdb_cache_find_id( be, tid, ei->bei_id, &ei, 1,
- locker, lock, ctx );
+ bdb_cache_find_id( op, tid, ei->bei_id, &ei, 1,
+ locker, lock );
*e = ei;
}
}
#ifndef BDB_HIER
int
bdb_dn2id_add(
- BackendDB *be,
+ Operation *op,
DB_TXN *txn,
EntryInfo *eip,
- Entry *e,
- void *ctx )
+ Entry *e )
{
- struct bdb_info *bdb = (struct bdb_info *) be->be_private;
+ struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
DB *db = bdb->bi_dn2id->bdi_db;
int rc;
DBT key, data;
key.size = e->e_nname.bv_len + 2;
key.ulen = key.size;
key.flags = DB_DBT_USERMEM;
- buf = sl_malloc( key.size, ctx );
+ buf = op->o_tmpalloc( key.size, op->o_tmpmemctx );
key.data = buf;
buf[0] = DN_BASE_PREFIX;
ptr.bv_val = buf + 1;
}
#ifndef BDB_MULTIPLE_SUFFIXES
- if( !be_issuffix( be, &ptr )) {
+ if( !be_issuffix( op->o_bd, &ptr )) {
#endif
buf[0] = DN_SUBTREE_PREFIX;
rc = db->put( db, txn, &key, &data, DB_NOOVERWRITE );
}
#ifdef BDB_MULTIPLE_SUFFIXES
- if( !be_issuffix( be, &ptr )) {
+ if( !be_issuffix( op->o_bd, &ptr )) {
#endif
dnParent( &ptr, &pdn );
key.data = pdn.bv_val-1;
ptr = pdn;
- rc = bdb_idl_insert_key( be, db, txn, &key, e->e_id );
+ rc = bdb_idl_insert_key( op->o_bd, db, txn, &key, e->e_id );
if( rc != 0 ) {
#ifdef NEW_LOGGING
#ifndef BDB_MULTIPLE_SUFFIXES
}
- while( !be_issuffix( be, &ptr )) {
+ while( !be_issuffix( op->o_bd, &ptr )) {
#else
for (;;) {
#endif
ptr.bv_val[-1] = DN_SUBTREE_PREFIX;
- rc = bdb_idl_insert_key( be, db, txn, &key, e->e_id );
+ rc = bdb_idl_insert_key( op->o_bd, db, txn, &key, e->e_id );
if( rc != 0 ) {
#ifdef NEW_LOGGING
break;
}
#ifdef BDB_MULTIPLE_SUFFIXES
- if( be_issuffix( be, &ptr )) break;
+ if( be_issuffix( op->o_bd, &ptr )) break;
#endif
dnParent( &ptr, &pdn );
#endif
done:
- sl_free( buf, ctx );
+ op->o_tmpfree( buf, op->o_tmpmemctx );
#ifdef NEW_LOGGING
LDAP_LOG ( INDEX, RESULTS, "<= bdb_dn2id_add: %d\n", rc, 0, 0 );
#else
int
bdb_dn2id_delete(
- BackendDB *be,
+ Operation *op,
DB_TXN *txn,
EntryInfo *eip,
- Entry *e,
- void *ctx )
+ Entry *e )
{
- struct bdb_info *bdb = (struct bdb_info *) be->be_private;
+ struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
DB *db = bdb->bi_dn2id->bdi_db;
int rc;
DBT key;
DBTzero( &key );
key.size = e->e_nname.bv_len + 2;
- buf = sl_malloc( key.size, ctx );
+ buf = op->o_tmpalloc( key.size, op->o_tmpmemctx );
key.data = buf;
key.flags = DB_DBT_USERMEM;
buf[0] = DN_BASE_PREFIX;
}
#ifndef BDB_MULTIPLE_SUFFIXES
- if( !be_issuffix( be, &ptr )) {
+ if( !be_issuffix( op->o_bd, &ptr )) {
#endif
buf[0] = DN_SUBTREE_PREFIX;
rc = db->del( db, txn, &key, 0 );
}
#ifdef BDB_MULTIPLE_SUFFIXES
- if( !be_issuffix( be, &ptr )) {
+ if( !be_issuffix( op->o_bd, &ptr )) {
#endif
dnParent( &ptr, &pdn );
key.data = pdn.bv_val - 1;
ptr = pdn;
- rc = bdb_idl_delete_key( be, db, txn, &key, e->e_id );
+ rc = bdb_idl_delete_key( op->o_bd, db, txn, &key, e->e_id );
if( rc != 0 ) {
#ifdef NEW_LOGGING
#ifndef BDB_MULTIPLE_SUFFIXES
}
- while( !be_issuffix( be, &ptr )) {
+ while( !be_issuffix( op->o_bd, &ptr )) {
#else
for (;;) {
#endif
ptr.bv_val[-1] = DN_SUBTREE_PREFIX;
- rc = bdb_idl_delete_key( be, db, txn, &key, e->e_id );
+ rc = bdb_idl_delete_key( op->o_bd, db, txn, &key, e->e_id );
if( rc != 0 ) {
#ifdef NEW_LOGGING
LDAP_LOG ( INDEX, ERR,
goto done;
}
#ifdef BDB_MULTIPLE_SUFFIXES
- if( be_issuffix( be, &ptr )) break;
+ if( be_issuffix( op->o_bd, &ptr )) break;
#endif
dnParent( &ptr, &pdn );
#endif
done:
- sl_free( buf, ctx );
+ op->o_tmpfree( buf, op->o_tmpmemctx );
#ifdef NEW_LOGGING
LDAP_LOG ( INDEX, RESULTS, "<= bdb_dn2id_delete %d\n", rc, 0, 0 );
#else
int
bdb_dn2id(
- BackendDB *be,
+ Operation *op,
DB_TXN *txn,
struct berval *dn,
- EntryInfo *ei,
- void *ctx )
+ EntryInfo *ei )
{
int rc;
DBT key, data;
- struct bdb_info *bdb = (struct bdb_info *) be->be_private;
+ struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
DB *db = bdb->bi_dn2id->bdi_db;
#ifdef NEW_LOGGING
#endif
DBTzero( &key );
key.size = dn->bv_len + 2;
- key.data = sl_malloc( key.size, ctx );
+ key.data = op->o_tmpalloc( key.size, op->o_tmpmemctx );
((char *)key.data)[0] = DN_BASE_PREFIX;
AC_MEMCPY( &((char *)key.data)[1], dn->bv_val, key.size - 1 );
#endif
}
- sl_free( key.data, ctx );
+ op->o_tmpfree( key.data, op->o_tmpmemctx );
return rc;
}
#endif
DBTzero( &key );
key.size = e->e_nname.bv_len + 2;
- key.data = sl_malloc( key.size, op->o_tmpmemctx );
+ key.data = op->o_tmpalloc( key.size, op->o_tmpmemctx );
((char *)key.data)[0] = DN_ONE_PREFIX;
AC_MEMCPY( &((char *)key.data)[1], e->e_nname.bv_val, key.size - 1 );
if ( bdb->bi_idl_cache_size ) {
rc = bdb_idl_cache_get( bdb, db, &key, NULL );
if ( rc != LDAP_NO_SUCH_OBJECT ) {
- sl_free( key.data, op->o_tmpmemctx );
+ op->o_tmpfree( key.data, op->o_tmpmemctx );
return rc;
}
}
data.dlen = sizeof(id);
rc = db->get( db, txn, &key, &data, bdb->bi_db_opflags );
- sl_free( key.data, op->o_tmpmemctx );
+ op->o_tmpfree( key.data, op->o_tmpmemctx );
#ifdef NEW_LOGGING
LDAP_LOG ( INDEX, DETAIL1,
key.size = e->e_nname.bv_len + 2;
key.ulen = key.size;
key.flags = DB_DBT_USERMEM;
- key.data = sl_malloc( key.size, op->o_tmpmemctx );
+ key.data = op->o_tmpalloc( key.size, op->o_tmpmemctx );
((char *)key.data)[0] = prefix;
AC_MEMCPY( &((char *)key.data)[1], e->e_nname.bv_val, key.size - 1 );
#endif
}
- sl_free( key.data, op->o_tmpmemctx );
+ op->o_tmpfree( key.data, op->o_tmpmemctx );
return rc;
}
#else /* BDB_HIER */
*/
int
hdb_dn2id_add(
- BackendDB *be,
+ Operation *op,
DB_TXN *txn,
EntryInfo *eip,
- Entry *e,
- void *ctx )
+ Entry *e )
{
- struct bdb_info *bdb = (struct bdb_info *) be->be_private;
+ struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
DB *db = bdb->bi_dn2id->bdi_db;
DBT key, data;
int rc, rlen, nrlen;
diskNode *d;
char *ptr;
- nrlen = dn_rdnlen( be, &e->e_nname );
+ nrlen = dn_rdnlen( op->o_bd, &e->e_nname );
if (nrlen) {
- rlen = dn_rdnlen( be, &e->e_name );
+ rlen = dn_rdnlen( op->o_bd, &e->e_name );
} else {
nrlen = e->e_nname.bv_len;
rlen = e->e_name.bv_len;
}
- d = sl_malloc(sizeof(diskNode) + rlen + nrlen, ctx);
+ d = op->o_tmpalloc(sizeof(diskNode) + rlen + nrlen, op->o_tmpmemctx);
d->entryID = e->e_id;
d->nrdnlen = nrlen;
ptr = lutil_strncopy( d->nrdn, e->e_nname.bv_val, nrlen );
rc = db->put( db, txn, &key, &data, DB_NODUPDATA );
}
- sl_free( d, ctx );
+ op->o_tmpfree( d, op->o_tmpmemctx );
return rc;
}
int
hdb_dn2id_delete(
- BackendDB *be,
+ Operation *op,
DB_TXN *txn,
EntryInfo *eip,
- Entry *e,
- void *ctx )
+ Entry *e )
{
- struct bdb_info *bdb = (struct bdb_info *) be->be_private;
+ struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
DB *db = bdb->bi_dn2id->bdi_db;
DBT key, data;
DBC *cursor;
rc = db->cursor( db, txn, &cursor, bdb->bi_db_opflags );
if ( rc ) return rc;
- d = sl_malloc( data.size, ctx );
+ d = op->o_tmpalloc( data.size, op->o_tmpmemctx );
d->entryID = e->e_id;
d->nrdnlen = BEI(e)->bei_nrdn.bv_len;
strcpy( d->nrdn, BEI(e)->bei_nrdn.bv_val );
rc = cursor->c_del( cursor, 0 );
}
cursor->c_close( cursor );
- sl_free( d, ctx );
+ op->o_tmpfree( d, op->o_tmpmemctx );
return rc;
}
int
hdb_dn2id(
- BackendDB *be,
+ Operation *op,
DB_TXN *txn,
struct berval *in,
- EntryInfo *ei,
- void *ctx )
+ EntryInfo *ei )
{
- struct bdb_info *bdb = (struct bdb_info *) be->be_private;
+ struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
DB *db = bdb->bi_dn2id->bdi_db;
DBT key, data;
DBC *cursor;
char *ptr;
ID idp = ei->bei_parent->bei_id;
- nrlen = dn_rdnlen( be, in );
+ nrlen = dn_rdnlen( op->o_bd, in );
if (!nrlen) nrlen = in->bv_len;
DBTzero(&key);
rc = db->cursor( db, txn, &cursor, bdb->bi_db_opflags );
if ( rc ) return rc;
- d = sl_malloc( data.size * 3, ctx );
+ d = op->o_tmpalloc( data.size * 3, op->o_tmpmemctx );
d->nrdnlen = nrlen;
ptr = lutil_strncopy( d->nrdn, in->bv_val, nrlen );
*ptr = '\0';
ei->bei_rdn.bv_val = ch_malloc( ei->bei_rdn.bv_len + 1 );
strcpy( ei->bei_rdn.bv_val, ptr );
}
- sl_free( d, ctx );
+ op->o_tmpfree( d, op->o_tmpmemctx );
return rc;
}
int
hdb_dn2id_parent(
- Backend *be,
+ Operation *op,
DB_TXN *txn,
EntryInfo *ei,
- ID *idp,
- void *ctx )
+ ID *idp )
{
- struct bdb_info *bdb = (struct bdb_info *) be->be_private;
+ struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
DB *db = bdb->bi_dn2id->bdi_db;
DBT key, data;
DBC *cursor;
if ( rc ) return rc;
data.ulen = sizeof(diskNode) + (SLAP_LDAPDN_MAXLEN * 2);
- d = sl_malloc( data.ulen, ctx );
+ d = op->o_tmpalloc( data.ulen, op->o_tmpmemctx );
data.data = d;
rc = cursor->c_get( cursor, &key, &data, DB_SET );
ptr = d->nrdn + ei->bei_nrdn.bv_len + 1;
ber_str2bv( ptr, ei->bei_rdn.bv_len, 1, &ei->bei_rdn );
}
- sl_free( d, ctx );
+ op->o_tmpfree( d, op->o_tmpmemctx );
return rc;
}
DBT key;
DBT data;
DBC *dbc;
- void *ctx;
+ Operation *op;
};
static int
if ( cx->prefix == DN_SUBTREE_PREFIX ) {
ID *save, idcurs;
- save = sl_malloc( BDB_IDL_SIZEOF( cx->tmp ), cx->ctx );
+ save = cx->op->o_tmpalloc( BDB_IDL_SIZEOF( cx->tmp ),
+ cx->op->o_tmpmemctx );
BDB_IDL_CPY( save, cx->tmp );
bdb_idl_union( cx->ids, cx->tmp );
cx->id = bdb_idl_next( save, &idcurs )) {
hdb_dn2idl_internal( cx );
}
- sl_free( save, cx->ctx );
+ cx->op->o_tmpfree( save, cx->op->o_tmpmemctx );
cx->rc = 0;
} else {
BDB_IDL_CPY( cx->ids, cx->tmp );
DN_ONE_PREFIX;
cx.ids = ids;
cx.buf = stack;
- cx.ctx = op->o_tmpmemctx;
+ cx.op = op;
BDB_IDL_ZERO( ids );
if ( cx.prefix == DN_SUBTREE_PREFIX ) {
bdb_unlocked_cache_return_entry_rw( &bdb->bi_cache, e, rw );
} else {
bdb_cache_return_entry_rw( bdb->bi_dbenv, &bdb->bi_cache, e, rw, &boi->boi_lock );
- sl_free( boi, o->o_tmpmemctx );
+ o->o_tmpfree( boi, o->o_tmpmemctx );
o->o_private = NULL;
}
} else {
dn2entry_retry:
/* can we find entry */
- rc = bdb_dn2entry( op->o_bd, txn, ndn, &ei, 0, locker, &lock, op->o_tmpmemctx );
+ rc = bdb_dn2entry( op, txn, ndn, &ei, 0, locker, &lock );
switch( rc ) {
case DB_NOTFOUND:
case 0:
* release it later??
*/
if ( op && !boi ) {
- boi = sl_calloc(1,sizeof(struct bdb_op_info),op->o_tmpmemctx);
+ boi = op->o_tmpcalloc(1,sizeof(struct bdb_op_info),op->o_tmpmemctx);
boi->boi_lock = lock;
op->o_private = boi;
}
return LDAP_OTHER;
}
+#if 0 /* No longer needed, our frees are in order so nothing accumulates */
mark = sl_mark(op->o_tmpmemctx);
+#endif
if( IS_SLAP_INDEX( mask, SLAP_INDEX_PRESENT ) ) {
rc = bdb_key_change( op->o_bd, db, txn, &presence_key, id, opid );
}
done:
+#if 0
sl_release( mark, op->o_tmpmemctx );
+#endif
return rc;
}
op->o_private = &opinfo;
/* get entry or ancestor */
- rs->sr_err = bdb_dn2entry( op->o_bd, ltid, &op->o_req_ndn, &ei, 1,
- locker, &lock, op->o_tmpmemctx );
+ rs->sr_err = bdb_dn2entry( op, ltid, &op->o_req_ndn, &ei, 1,
+ locker, &lock );
if ( rs->sr_err != 0 ) {
#ifdef NEW_LOGGING
op->o_private = &opinfo;
/* get entry */
- rs->sr_err = bdb_dn2entry( op->o_bd, ltid, &op->o_req_ndn, &ei, 1,
- locker, &lock, op->o_tmpmemctx );
+ rs->sr_err = bdb_dn2entry( op, ltid, &op->o_req_ndn, &ei, 1,
+ locker, &lock );
switch( rs->sr_err ) {
case 0:
* children.
*/
eip = ei->bei_parent;
- rs->sr_err = bdb_cache_find_id( op->o_bd, ltid,
- eip->bei_id, &eip, 0, locker, &plock, op->o_tmpmemctx );
+ rs->sr_err = bdb_cache_find_id( op, ltid,
+ eip->bei_id, &eip, 0, locker, &plock );
switch( rs->sr_err ) {
case 0:
/* newSuperior == entry being moved?, if so ==> ERROR */
/* Get Entry with dn=newSuperior. Does newSuperior exist? */
- rs->sr_err = bdb_dn2entry( op->o_bd, ltid, np_ndn,
- &neip, 0, locker, &nplock, op->o_tmpmemctx );
+ rs->sr_err = bdb_dn2entry( op, ltid, np_ndn,
+ &neip, 0, locker, &nplock );
switch( rs->sr_err ) {
case 0: np = neip->bei_e;
/* Shortcut the search */
nei = neip ? neip : eip;
- rs->sr_err = bdb_cache_find_ndn ( op->o_bd, ltid, &new_ndn,
- &nei, locker, op->o_tmpmemctx );
+ rs->sr_err = bdb_cache_find_ndn ( op, ltid, &new_ndn, &nei, locker );
if ( nei ) bdb_cache_entryinfo_unlock( nei );
switch( rs->sr_err ) {
case DB_LOCK_DEADLOCK:
e = &dummy;
/* delete old one */
- rs->sr_err = bdb_dn2id_delete( op->o_bd, lt2, eip, e,
- op->o_tmpmemctx );
+ rs->sr_err = bdb_dn2id_delete( op, lt2, eip, e );
if ( rs->sr_err != 0 ) {
#ifdef NEW_LOGGING
LDAP_LOG ( OPERATION, ERR,
new_ndn.bv_val = NULL;
/* add new one */
- rs->sr_err = bdb_dn2id_add( op->o_bd, lt2, neip ? neip : eip, e,
- op->o_tmpmemctx );
+ rs->sr_err = bdb_dn2id_add( op, lt2, neip ? neip : eip, e );
if ( rs->sr_err != 0 ) {
#ifdef NEW_LOGGING
LDAP_LOG ( OPERATION, ERR,
op->o_private = &opinfo;
/* get entry */
- rc = bdb_dn2entry( op->o_bd, ltid, &ndn, &ei, 0 , locker, &lock, op->o_tmpmemctx );
+ rc = bdb_dn2entry( op, ltid, &ndn, &ei, 0 , locker, &lock );
switch(rc) {
case DB_LOCK_DEADLOCK:
*/
#define bdb_dn2entry BDB_SYMBOL(dn2entry)
-int bdb_dn2entry LDAP_P(( BackendDB *be, DB_TXN *tid,
+int bdb_dn2entry LDAP_P(( Operation *op, DB_TXN *tid,
struct berval *dn, EntryInfo **e, int matched,
- u_int32_t locker, DB_LOCK *lock, void *ctx));
+ u_int32_t locker, DB_LOCK *lock ));
/*
* dn2id.c
#define bdb_dn2idl BDB_SYMBOL(dn2idl)
int bdb_dn2id(
- BackendDB *be,
+ Operation *op,
DB_TXN *tid,
struct berval *dn,
- EntryInfo *ei,
- void *ctx );
+ EntryInfo *ei );
int bdb_dn2id_add(
- BackendDB *be,
+ Operation *op,
DB_TXN *tid,
EntryInfo *eip,
- Entry *e,
- void *ctx );
+ Entry *e );
int bdb_dn2id_delete(
- BackendDB *be,
+ Operation *op,
DB_TXN *tid,
EntryInfo *eip,
- Entry *e,
- void *ctx );
+ Entry *e );
int bdb_dn2id_children(
Operation *op,
#define bdb_fix_dn BDB_SYMBOL(fix_dn)
int bdb_dn2id_parent(
- Backend *be,
+ Operation *op,
DB_TXN *txn,
EntryInfo *ei,
- ID *idp,
- void *ctx );
+ ID *idp );
int bdb_dup_compare(
DB *db,
DB_LOCK *lock
);
int bdb_cache_find_ndn(
- Backend *be,
+ Operation *op,
DB_TXN *txn,
struct berval *ndn,
EntryInfo **res,
- u_int32_t locker,
- void *ctx
+ u_int32_t locker
);
int bdb_cache_find_id(
- Backend *be,
+ Operation *op,
DB_TXN *tid,
ID id,
EntryInfo **eip,
int islocked,
u_int32_t locker,
- DB_LOCK *lock,
- void *ctx
+ DB_LOCK *lock
);
int bdb_cache_delete(
Cache *cache,
dn2entry_retry:
/* get entry */
- rc = bdb_dn2entry( op->o_bd, NULL, &op->o_req_ndn, &ei, 1, locker,
- &lock, op->o_tmpmemctx );
+ rc = bdb_dn2entry( op, NULL, &op->o_req_ndn, &ei, 1, locker, &lock );
e = ei->bei_e;
switch(rc) {
LOCK_ID_FREE ( bdb->bi_dbenv, locker );
if (rs->sr_matched) {
- sl_free( (char *)rs->sr_matched, op->o_tmpmemctx );
+ op->o_tmpfree( (char *)rs->sr_matched, op->o_tmpmemctx );
rs->sr_matched = NULL;
}
return rc;
break;
}
- rs->sr_err = bdb_dn2entry( op->o_bd, NULL, &ndn, &ei,
- 0, locker, &lockr, op->o_tmpmemctx );
+ rs->sr_err = bdb_dn2entry( op, NULL, &ndn, &ei,
+ 0, locker, &lockr );
if ( ei ) e = ei->bei_e;
else e = NULL;
ida = bdb_idl_next(curscop, &cursora))
{
ei = NULL;
- rs->sr_err = bdb_cache_find_id(op->o_bd, NULL,
- ida, &ei, 0, locker, &lockr, op->o_tmpmemctx );
+ rs->sr_err = bdb_cache_find_id(op, NULL,
+ ida, &ei, 0, locker, &lockr );
if (rs->sr_err != LDAP_SUCCESS) {
continue;
}
* Set the name so that the scope's IDL can be retrieved.
*/
ei = NULL;
- rs->sr_err = bdb_cache_find_id(op->o_bd, NULL, ido, &ei,
- 0, locker, &locka, op->o_tmpmemctx );
+ rs->sr_err = bdb_cache_find_id(op, NULL, ido, &ei,
+ 0, locker, &locka );
if (rs->sr_err != LDAP_SUCCESS) goto nextido;
e = ei->bei_e;
}
} else {
dn2entry_retry:
/* get entry with reader lock */
- rs->sr_err = bdb_dn2entry( op->o_bd, NULL, &sop->o_req_ndn, &ei,
- 1, locker, &lock, op->o_tmpmemctx );
+ rs->sr_err = bdb_dn2entry( op, NULL, &sop->o_req_ndn, &ei,
+ 1, locker, &lock );
}
switch(rs->sr_err) {
id2entry_retry:
/* get the entry with reader lock */
ei = NULL;
- rs->sr_err = bdb_cache_find_id( op->o_bd, NULL,
- id, &ei, 0, locker, &lock, op->o_tmpmemctx );
+ rs->sr_err = bdb_cache_find_id( op, NULL,
+ id, &ei, 0, locker, &lock );
if (rs->sr_err == LDAP_BUSY) {
rs->sr_text = "ldap server busy";
#else
{
EntryInfo *ei = NULL;
- rc = bdb_cache_find_id( be, NULL, id, &ei, 0, 0,
- NULL, NULL );
+ Operation op = {0};
+
+ op.o_bd = be;
+ op.o_tmpmemctx = NULL;
+ op.o_tmpmfuncs = &ch_mfuncs;
+
+ rc = bdb_cache_find_id( &op, NULL, id, &ei, 0, 0, NULL );
if ( rc == LDAP_SUCCESS )
e = ei->bei_e;
}
}
static int bdb_tool_next_id(
- BackendDB *be,
+ Operation *op,
DB_TXN *tid,
Entry *e,
struct berval *text,
int hole,
u_int32_t locker )
{
- struct bdb_info *bdb = (struct bdb_info *) be->be_private;
+ struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
struct berval dn = e->e_nname;
struct berval pdn;
EntryInfo *ei = NULL;
int rc;
- rc = bdb_cache_find_ndn( be, tid, &dn, &ei, locker, NULL );
+ rc = bdb_cache_find_ndn( op, tid, &dn, &ei, locker );
if ( ei ) bdb_cache_entryinfo_unlock( ei );
if ( rc == DB_NOTFOUND ) {
- if ( be_issuffix( be, &dn ) ) {
+ if ( be_issuffix( op->o_bd, &dn ) ) {
pdn = slap_empty_bv;
} else {
dnParent( &dn, &pdn );
e->e_nname = pdn;
- rc = bdb_tool_next_id( be, tid, e, text, 1, locker );
+ rc = bdb_tool_next_id( op, tid, e, text, 1, locker );
if ( rc ) {
return rc;
}
}
- rc = bdb_next_id( be, tid, &e->e_id );
+ rc = bdb_next_id( op->o_bd, tid, &e->e_id );
if ( rc ) {
snprintf( text->bv_val, text->bv_len,
"next_id failed: %s (%d)",
return rc;
}
e->e_nname = dn;
- rc = bdb_dn2id_add( be, tid, ei, e, NULL );
+ rc = bdb_dn2id_add( op, tid, ei, e );
if ( rc ) {
snprintf( text->bv_val, text->bv_len,
"dn2id_add failed: %s (%d)",
return NOID;
}
+ op.o_bd = be;
+ op.o_tmpmemctx = NULL;
+ op.o_tmpmfuncs = &ch_mfuncs;
+
locker = TXN_ID( tid );
/* add dn2id indices */
- rc = bdb_tool_next_id( be, tid, e, text, 0, locker );
+ rc = bdb_tool_next_id( &op, tid, e, text, 0, locker );
if( rc != 0 ) {
goto done;
}
goto done;
}
- op.o_bd = be;
- op.o_tmpmemctx = NULL;
- op.o_tmpmfuncs = &ch_mfuncs;
rc = bdb_index_entry_add( &op, tid, e );
if( rc != 0 ) {
snprintf( text->bv_val, text->bv_len,
(long) id, e->e_dn, 0 );
#endif
+ op.o_bd = be;
+ op.o_tmpmemctx = NULL;
+ op.o_tmpmfuncs = &ch_mfuncs;
+
#ifndef BDB_HIER
/* add dn2id indices */
- rc = bdb_dn2id_add( be, tid, NULL, e, NULL );
+ rc = bdb_dn2id_add( &op, tid, NULL, e );
if( rc != 0 && rc != DB_KEYEXIST ) {
#ifdef NEW_LOGGING
LDAP_LOG ( TOOLS, ERR,
}
#endif
- op.o_bd = be;
- op.o_tmpmemctx = NULL;
- op.o_tmpmfuncs = &ch_mfuncs;
rc = bdb_index_entry_add( &op, tid, e );
done: