{
int rc;
struct mdb_info *mdb;
- MDB_txn *tid;
Operation op = {0};
Opheader ohdr = {0};
mdb_cursor_close( cursor );
cursor = NULL;
}
- rc = mdb_txn_begin( mdb->mi_dbenv, NULL, 0, &tid );
- if( rc != 0 ) {
- snprintf( text->bv_val, text->bv_len,
- "txn_begin failed: %s (%d)",
- mdb_strerror(rc), rc );
- Debug( LDAP_DEBUG_ANY,
- "=> " LDAP_XSTRING(mdb_tool_entry_modify) ": %s\n",
- text->bv_val, 0, 0 );
- return NOID;
+ if ( !txn ) {
+ rc = mdb_txn_begin( mdb->mi_dbenv, NULL, 0, &txn );
+ if( rc != 0 ) {
+ snprintf( text->bv_val, text->bv_len,
+ "txn_begin failed: %s (%d)",
+ mdb_strerror(rc), rc );
+ Debug( LDAP_DEBUG_ANY,
+ "=> " LDAP_XSTRING(mdb_tool_entry_modify) ": %s\n",
+ text->bv_val, 0, 0 );
+ return NOID;
+ }
}
op.o_hdr = &ohdr;
op.o_tmpmfuncs = &ch_mfuncs;
/* id2entry index */
- rc = mdb_id2entry_update( &op, tid, NULL, e );
+ rc = mdb_id2entry_update( &op, txn, NULL, e );
if( rc != 0 ) {
snprintf( text->bv_val, text->bv_len,
"id2entry_update failed: err=%d", rc );
done:
if( rc == 0 ) {
- rc = mdb_txn_commit( tid );
+ rc = mdb_txn_commit( txn );
if( rc != 0 ) {
snprintf( text->bv_val, text->bv_len,
"txn_commit failed: %s (%d)",
}
} else {
- mdb_txn_abort( tid );
+ mdb_txn_abort( txn );
snprintf( text->bv_val, text->bv_len,
"txn_aborted! %s (%d)",
mdb_strerror(rc), rc );
text->bv_val, 0, 0 );
e->e_id = NOID;
}
+ txn = NULL;
return e->e_id;
}