data.mv_data = d;
rc = mdb_cursor_get( cursor, &key, &data, MDB_GET_BOTH );
op->o_tmpfree( d, op->o_tmpmemctx );
- if ( rc == MDB_NOTFOUND ) {
- if ( matched && matched->bv_len ) {
- ptr = op->o_tmpalloc( matched->bv_len+1, op->o_tmpmemctx );
- strcpy( ptr, matched->bv_val );
- matched->bv_val = ptr;
- }
- }
if ( rc ) {
mdb_cursor_close( cursor );
break;
}
}
*id = nid;
+ if ( matched && matched->bv_len ) {
+ ptr = op->o_tmpalloc( matched->bv_len+1, op->o_tmpmemctx );
+ strcpy( ptr, matched->bv_val );
+ matched->bv_val = ptr;
+ }
done:
if( rc != 0 ) {
memcpy( nname->bv_val, ndn, nname->bv_len );
nname->bv_val[nname->bv_len] = '\0';
}
- mdb_cursor_close( cursor );
return rc;
}
if( rc == 0 ) {
(*e)->e_id = id;
(*e)->e_bv = eh.bv;
+ (*e)->e_name.bv_val = NULL;
+ (*e)->e_nname.bv_val = NULL;
} else {
ch_free( eh.bv.bv_val );
}
{
struct mdb_info *mdb = (struct mdb_info *) op->o_bd->be_private;
struct mdb_op_info *moi = NULL;
- MDB_txn *txn = NULL;
int rc;
/* slapMode : SLAP_SERVER_MODE, SLAP_TOOL_MODE,
mdb_op_info *moi = NULL;
OpExtra *oex;
+ assert( op != NULL );
+
if ( !mdb || !moip ) return -1;
/* If no op was provided, try to find the ctx anyway... */
if ( !moi ) {
if ( op ) {
moi = op->o_tmpalloc(sizeof(struct mdb_op_info),op->o_tmpmemctx);
- LDAP_SLIST_INSERT_HEAD( &op->o_extra, &moi->moi_oe, oe_next );
} else {
moi = ch_malloc(sizeof(mdb_op_info));
}
moi->moi_flag = MOI_FREEIT;
*moip = moi;
}
+ LDAP_SLIST_INSERT_HEAD( &op->o_extra, &moi->moi_oe, oe_next );
moi->moi_oe.oe_key = mdb;
moi->moi_ref = 0;
moi->moi_txn = NULL;
} else {
moi->moi_txn = data;
}
+ moi->moi_flag |= MOI_READER;
} else {
if ( moi->moi_ref < 1 ) {
moi->moi_ref = 0;
#include "back-mdb.h"
#include "idl.h"
-static MDB_txn *txn = NULL;
+static MDB_txn *txn = NULL, *txi = NULL;
static MDB_cursor *cursor = NULL, *idcursor = NULL;
static MDB_val key, data;
static EntryHeader eh;
if ( !BER_BVISNULL( &dn )) {
e->e_name = dn;
e->e_nname = ndn;
+ } else {
+ e->e_name.bv_val = NULL;
+ e->e_nname.bv_val = NULL;
}
e->e_bv = eh.bv;
goto done;
}
-#if 0
- if ( !mdb->bi_linear_index )
- rc = mdb_tool_index_add( &op, tid, e );
+ rc = mdb_tool_index_add( &op, txn, e );
if( rc != 0 ) {
snprintf( text->bv_val, text->bv_len,
"index_entry_add failed: %s (%d)",
rc == LDAP_OTHER ? "Internal error" :
- db_strerror(rc), rc );
+ mdb_strerror(rc), rc );
Debug( LDAP_DEBUG_ANY,
"=> " LDAP_XSTRING(mdb_tool_entry_put) ": %s\n",
text->bv_val, 0, 0 );
goto done;
}
-#endif
/* id2entry index */
struct mdb_info *mi = (struct mdb_info *) be->be_private;
int rc;
Entry *e;
- MDB_txn *tid = NULL;
Operation op = {0};
Opheader ohdr = {0};
return -1;
}
- if ( !txn ) {
- rc = mdb_txn_begin( mi->mi_dbenv, 0, &tid );
+ if ( !txi ) {
+ rc = mdb_txn_begin( mi->mi_dbenv, 0, &txi );
if( rc != 0 ) {
Debug( LDAP_DEBUG_ANY,
"=> " LDAP_XSTRING(mdb_tool_entry_reindex) ": "
op.o_tmpmemctx = NULL;
op.o_tmpmfuncs = &ch_mfuncs;
- rc = mdb_tool_index_add( &op, tid, e );
+ rc = mdb_tool_index_add( &op, txi, e );
done:
if( rc == 0 ) {
mdb_writes++;
if ( mdb_writes >= mdb_writes_per_commit ) {
- rc = mdb_txn_commit( tid );
+ rc = mdb_txn_commit( txi );
if( rc != 0 ) {
Debug( LDAP_DEBUG_ANY,
"=> " LDAP_XSTRING(mdb_tool_entry_reindex)
mdb_strerror(rc), rc, 0 );
e->e_id = NOID;
}
+ txi = NULL;
}
} else {
- mdb_txn_abort( tid );
+ mdb_txn_abort( txi );
Debug( LDAP_DEBUG_ANY,
"=> " LDAP_XSTRING(mdb_tool_entry_reindex)
": txn_aborted! %s (%d)\n",
mdb_strerror(rc), rc, 0 );
e->e_id = NOID;
+ txi = NULL;
}
mdb_entry_release( &op, e, 0 );