}
/* dn2id index */
- rs->sr_err = bdb_dn2id_add( op->o_bd, lt2, &pdn, op->oq_add.rs_e );
+ rs->sr_err = bdb_dn2id_add( op->o_bd, lt2, &pdn, op->oq_add.rs_e,
+ op->o_tmpmemctx );
if ( rs->sr_err != 0 ) {
#ifdef NEW_LOGGING
LDAP_LOG ( OPERATION, ERR,
};
#define bi_id2entry bi_databases[BDB_ID2ENTRY]
-#ifdef BDB_HIER
-#define bi_id2parent bi_databases[BDB_ID2PARENT]
-#else
#define bi_dn2id bi_databases[BDB_DN2ID]
-#endif
struct bdb_op_info {
BackendDB* boi_bdb;
{
struct bdb_info *bdb = (struct bdb_info *) be->be_private;
EntryInfo ei, *eip, *ei2;
- ID id;
int rc = 0;
char *ptr;
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, &id, ctx );
+ rc = bdb_dn2id( be, txn, &ei.bei_nrdn, &ei, ctx );
if (rc) {
bdb_cache_entryinfo_lock( eip );
*res = eip;
/* DN exists but needs to be added to cache */
ei.bei_nrdn.bv_len = len;
rc = bdb_entryinfo_add_internal( bdb,
- eip, id, &ei.bei_nrdn, &ei2, locker );
+ eip, ei.bei_id, &ei.bei_nrdn, &ei2, locker );
/* add_internal left eip and c_rwlock locked */
ldap_pvt_thread_rdwr_wunlock( &bdb->bi_cache.c_rwlock );
if ( rc ) {
}
/* delete from dn2id */
- rs->sr_err = bdb_dn2id_delete( op->o_bd, lt2, pdn.bv_val, e );
+ rs->sr_err = bdb_dn2id_delete( op->o_bd, lt2, pdn.bv_val, e,
+ op->o_tmpmemctx );
if ( rs->sr_err != 0 ) {
switch( rs->sr_err ) {
case DB_LOCK_DEADLOCK:
BackendDB *be,
DB_TXN *txn,
struct berval *pbv,
- Entry *e )
+ Entry *e,
+ void *ctx )
{
struct bdb_info *bdb = (struct bdb_info *) be->be_private;
DB *db = bdb->bi_dn2id->bdi_db;
key.size = e->e_nname.bv_len + 2;
key.ulen = key.size;
key.flags = DB_DBT_USERMEM;
- buf = ch_malloc( key.size );
+ buf = sl_malloc( key.size, ctx );
key.data = buf;
buf[0] = DN_BASE_PREFIX;
ptr.bv_val = buf + 1;
#endif
done:
- ch_free( buf );
+ sl_free( buf, ctx );
#ifdef NEW_LOGGING
LDAP_LOG ( INDEX, RESULTS, "<= bdb_dn2id_add: %d\n", rc, 0, 0 );
#else
BackendDB *be,
DB_TXN *txn,
char *pdnc,
- Entry *e )
+ Entry *e,
+ void *ctx )
{
struct bdb_info *bdb = (struct bdb_info *) be->be_private;
DB *db = bdb->bi_dn2id->bdi_db;
DBTzero( &key );
key.size = e->e_nname.bv_len + 2;
- buf = ch_malloc( key.size );
+ buf = sl_malloc( key.size, ctx );
key.data = buf;
key.flags = DB_DBT_USERMEM;
buf[0] = DN_BASE_PREFIX;
#endif
done:
- ch_free( buf );
+ sl_free( buf, ctx );
#ifdef NEW_LOGGING
LDAP_LOG ( INDEX, RESULTS, "<= bdb_dn2id_delete %d\n", rc, 0, 0 );
#else
BackendDB *be,
DB_TXN *txn,
struct berval *dn,
- ID *id,
+ EntryInfo *ei,
void *ctx )
{
int rc;
Debug( LDAP_DEBUG_TRACE, "=> bdb_dn2id( \"%s\" )\n", dn->bv_val, 0, 0 );
#endif
- assert (id);
-
DBTzero( &key );
key.size = dn->bv_len + 2;
key.data = sl_malloc( key.size, ctx );
/* store the ID */
DBTzero( &data );
- data.data = id;
+ data.data = &ei->bei_id;
data.ulen = sizeof(ID);
data.flags = DB_DBT_USERMEM;
} else {
#ifdef NEW_LOGGING
LDAP_LOG ( INDEX, RESULTS,
- "<= bdb_dn2id: got id=0x%08lx\n", *id, 0, 0 );
+ "<= bdb_dn2id: got id=0x%08lx\n", ei->bei_id, 0, 0 );
#else
Debug( LDAP_DEBUG_TRACE, "<= bdb_dn2id: got id=0x%08lx\n",
- *id, 0, 0 );
+ ei->bei_id, 0, 0 );
#endif
}
int flags;
} bdbi_databases[] = {
{ "id2entry" BDB_SUFFIX, "id2entry", DB_BTREE, 0 },
-#ifdef BDB_HIER
- { "id2parent" BDB_SUFFIX, "id2parent", DB_BTREE, 0 },
-#else
{ "dn2id" BDB_SUFFIX, "dn2id", DB_BTREE, 0 },
-#endif
{ NULL, NULL, 0, 0 }
};
ldap_pvt_thread_mutex_init( &bdb->bi_lastid_mutex );
ldap_pvt_thread_mutex_init( &bdb->bi_cache.lru_mutex );
ldap_pvt_thread_rdwr_init ( &bdb->bi_cache.c_rwlock );
-#ifdef BDB_HIER
- ldap_pvt_thread_rdwr_init( &bdb->bi_tree_rdwr );
-#endif
be->be_private = bdb;
}
/* <insert> open (and create) index databases */
-#ifdef BDB_HIER
- rc = bdb_build_tree( be );
-#endif
return 0;
}
if( bdb->bi_dbenv_home ) ch_free( bdb->bi_dbenv_home );
-#ifdef BDB_HIER
- ldap_pvt_thread_rdwr_destroy( &bdb->bi_tree_rdwr );
-#endif
ldap_pvt_thread_rdwr_destroy ( &bdb->bi_cache.c_rwlock );
ldap_pvt_thread_mutex_destroy( &bdb->bi_cache.lru_mutex );
ldap_pvt_thread_mutex_destroy( &bdb->bi_lastid_mutex );
e = &dummy;
/* delete old one */
- rs->sr_err = bdb_dn2id_delete( op->o_bd, lt2, p_ndn.bv_val, e );
+ rs->sr_err = bdb_dn2id_delete( op->o_bd, lt2, p_ndn.bv_val, e,
+ op->o_tmpmemctx );
if ( rs->sr_err != 0 ) {
switch( rs->sr_err ) {
case DB_LOCK_DEADLOCK:
new_ndn.bv_val = NULL;
#endif
/* add new one */
- rs->sr_err = bdb_dn2id_add( op->o_bd, lt2, np_ndn, e );
+ rs->sr_err = bdb_dn2id_add( op->o_bd, lt2, np_ndn, e,
+ op->o_tmpmemctx );
if ( rs->sr_err != 0 ) {
switch( rs->sr_err ) {
case DB_LOCK_DEADLOCK:
BackendDB *be,
DB_TXN *tid,
struct berval *dn,
- ID *id,
+ EntryInfo *ei,
void *ctx );
int bdb_dn2id_add(
BackendDB *be,
DB_TXN *tid,
struct berval *pdn,
- Entry *e );
+ Entry *e,
+ void *ctx );
int bdb_dn2id_delete(
BackendDB *be,
DB_TXN *tid,
char *pdn,
- Entry *e );
+ Entry *e,
+ void *ctx );
int bdb_dn2id_children(
Operation *op,
if ( rc == DB_NOTFOUND ) {
rc = 0;
+ rs->sr_matched = NULL;
if ( e != NULL ) {
- rs->sr_matched = ch_strdup( e->e_name.bv_val );
-
#ifdef NEW_LOGGING
- LDAP_LOG ( OPERATION, DETAIL1,
+ LDAP_LOG ( OPERATION, DETAIL1,
"bdb_referrals: op=%ld target=\"%s\" matched=\"%s\"\n",
(long) op->o_tag, op->o_req_dn.bv_val, rs->sr_matched );
#else
if( is_entry_referral( e ) ) {
rc = LDAP_OTHER;
rs->sr_ref = get_entry_referrals( op, e );
+ if ( rs->sr_ref ) {
+ rs->sr_matched = ber_strdup_x(
+ e->e_name.bv_val, op->o_tmpmemctx );
+ }
}
bdb_cache_return_entry_r (bdb->bi_dbenv, &bdb->bi_cache, e, &lock);
}
LOCK_ID_FREE ( bdb->bi_dbenv, locker );
- free( (char *)rs->sr_matched );
- rs->sr_matched = NULL;
+ if (rs->sr_matched) {
+ sl_free( (char *)rs->sr_matched, op->o_tmpmemctx );
+ rs->sr_matched = NULL;
+ }
return rc;
}
return rc;
}
e->e_nname = dn;
- rc = bdb_dn2id_add( be, tid, &pdn, e );
+ rc = bdb_dn2id_add( be, tid, &pdn, e, NULL );
if ( rc ) {
snprintf( text->bv_val, text->bv_len,
"dn2id_add failed: %s (%d)",
} else {
dnParent( &e->e_nname, &pdn );
}
- rc = bdb_dn2id_add( be, tid, &pdn, e );
+ rc = bdb_dn2id_add( be, tid, &pdn, e, NULL );
if( rc != 0 && rc != DB_KEYEXIST ) {
#ifdef NEW_LOGGING
LDAP_LOG ( TOOLS, ERR,