}
/* begin transaction */
- if( bdb->bi_txn ) {
- rc = txn_begin( bdb->bi_dbenv, NULL, <id,
- bdb->bi_db_opflags );
- text = NULL;
- if( rc != 0 ) {
- Debug( LDAP_DEBUG_TRACE,
- "bdb_add: txn_begin failed: %s (%d)\n",
- db_strerror(rc), rc, 0 );
- rc = LDAP_OTHER;
- text = "internal error";
- goto return_results;
- }
+ rc = txn_begin( bdb->bi_dbenv, NULL, <id,
+ bdb->bi_db_opflags );
+ text = NULL;
+ if( rc != 0 ) {
+ Debug( LDAP_DEBUG_TRACE,
+ "bdb_add: txn_begin failed: %s (%d)\n",
+ db_strerror(rc), rc, 0 );
+ rc = LDAP_OTHER;
+ text = "internal error";
+ goto return_results;
+ }
#if 0
- lockid = TXN_ID( ltid );
+ lockid = TXN_ID( ltid );
#endif
- }
opinfo.boi_bdb = be;
opinfo.boi_txn = ltid;
goto return_results;
}
- if( bdb->bi_txn ) {
- rc = txn_commit( ltid, 0 );
- }
+ rc = txn_commit( ltid, 0 );
ltid = NULL;
op->o_private = NULL;
int bi_nrdns;
#endif
- int bi_txn;
int bi_txn_cp;
u_int32_t bi_txn_cp_min;
u_int32_t bi_txn_cp_kbyte;
#include "back-bdb.h"
-#define SLAP_BDB_ALLOW_DBNOTXN
#ifdef DB_DIRTY_READ
# define SLAP_BDB_ALLOW_DIRTY_READ
#endif
}
bdb->bi_dbenv_home = ch_strdup( argv[1] );
-#ifdef SLAP_BDB_ALLOW_DBNOTXN
- /* turn off transactions, use CDB mode instead */
- } else if ( strcasecmp( argv[0], "dbnotxn" ) == 0 ) {
- bdb->bi_txn = 0;
-#endif
#ifdef SLAP_BDB_ALLOW_DIRTY_READ
} else if ( strcasecmp( argv[0], "dirtyread" ) == 0 ) {
bdb->bi_db_opflags |= DB_DIRTY_READ;
ldap_pvt_thread_yield();
}
- if( bdb->bi_txn ) {
- /* begin transaction */
- rc = txn_begin( bdb->bi_dbenv, NULL, <id,
- bdb->bi_db_opflags );
- text = NULL;
- if( rc != 0 ) {
- Debug( LDAP_DEBUG_TRACE,
- "bdb_delete: txn_begin failed: %s (%d)\n",
- db_strerror(rc), rc, 0 );
- rc = LDAP_OTHER;
- text = "internal error";
- goto return_results;
- }
+ /* begin transaction */
+ rc = txn_begin( bdb->bi_dbenv, NULL, <id,
+ bdb->bi_db_opflags );
+ text = NULL;
+ if( rc != 0 ) {
+ Debug( LDAP_DEBUG_TRACE,
+ "bdb_delete: txn_begin failed: %s (%d)\n",
+ db_strerror(rc), rc, 0 );
+ rc = LDAP_OTHER;
+ text = "internal error";
+ goto return_results;
+ }
#if 0
- lockid = TXN_ID( ltid );
+ lockid = TXN_ID( ltid );
#endif
- }
opinfo.boi_bdb = be;
opinfo.boi_txn = ltid;
ldap_pvt_thread_mutex_unlock( &bdb->bi_lastid_mutex );
#endif
- if( bdb->bi_txn ) {
- rc = txn_commit( ltid, 0 );
- }
+ rc = txn_commit( ltid, 0 );
ltid = NULL;
op->o_private = NULL;
bdb->bi_dbenv_home = ch_strdup( BDB_DBENV_HOME );
bdb->bi_dbenv_xflags = 0;
bdb->bi_dbenv_mode = DEFAULT_MODE;
- bdb->bi_txn = 1; /* default to using transactions */
bdb->bi_cache.c_maxsize = DEFAULT_CACHE_SIZE;
return rc;
}
- flags = DB_INIT_MPOOL | DB_THREAD | DB_CREATE;
-
- if( bdb->bi_txn ) {
- flags |= DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_TXN | DB_RECOVER;
-
- } else {
- flags |= DB_INIT_CDB;
- bdb->bi_txn_cp = 0;
- }
+ flags = DB_INIT_MPOOL | DB_THREAD | DB_CREATE
+ | DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_TXN | DB_RECOVER;
bdb->bi_dbenv->set_errpfx( bdb->bi_dbenv, be->be_suffix[0]->bv_val );
bdb->bi_dbenv->set_errcall( bdb->bi_dbenv, bdb_errcall );
/* close db environment */
if( bdb->bi_dbenv ) {
/* force a checkpoint */
- if( bdb->bi_txn ) {
- rc = TXN_CHECKPOINT( bdb->bi_dbenv, 0, 0, DB_FORCE );
- if( rc != 0 ) {
- Debug( LDAP_DEBUG_ANY,
- "bdb_db_destroy: txn_checkpoint failed: %s (%d)\n",
- db_strerror(rc), rc, 0 );
- }
+ rc = TXN_CHECKPOINT( bdb->bi_dbenv, 0, 0, DB_FORCE );
+ if( rc != 0 ) {
+ Debug( LDAP_DEBUG_ANY,
+ "bdb_db_destroy: txn_checkpoint failed: %s (%d)\n",
+ db_strerror(rc), rc, 0 );
}
bdb_cache_release_all (&bdb->bi_cache);
ldap_pvt_thread_yield();
}
- if( bdb->bi_txn ) {
- /* begin transaction */
- rc = txn_begin( bdb->bi_dbenv, NULL, <id,
- bdb->bi_db_opflags );
- text = NULL;
- if( rc != 0 ) {
- Debug( LDAP_DEBUG_TRACE,
- "bdb_modify: txn_begin failed: %s (%d)\n",
- db_strerror(rc), rc, 0 );
- rc = LDAP_OTHER;
- text = "internal error";
- goto return_results;
- }
+ /* begin transaction */
+ rc = txn_begin( bdb->bi_dbenv, NULL, <id,
+ bdb->bi_db_opflags );
+ text = NULL;
+ if( rc != 0 ) {
+ Debug( LDAP_DEBUG_TRACE,
+ "bdb_modify: txn_begin failed: %s (%d)\n",
+ db_strerror(rc), rc, 0 );
+ rc = LDAP_OTHER;
+ text = "internal error";
+ goto return_results;
}
opinfo.boi_bdb = be;
goto return_results;
}
- if( bdb->bi_txn ) {
- rc = txn_commit( ltid, 0 );
- }
+ rc = txn_commit( ltid, 0 );
ltid = NULL;
op->o_private = NULL;
ldap_pvt_thread_yield();
}
- if( bdb->bi_txn ) {
- /* begin transaction */
- rc = txn_begin( bdb->bi_dbenv, NULL, <id,
- bdb->bi_db_opflags );
- text = NULL;
- if( rc != 0 ) {
- Debug( LDAP_DEBUG_TRACE,
- "bdb_delete: txn_begin failed: %s (%d)\n",
- db_strerror(rc), rc, 0 );
- rc = LDAP_OTHER;
- text = "internal error";
- goto return_results;
- }
+ /* begin transaction */
+ rc = txn_begin( bdb->bi_dbenv, NULL, <id,
+ bdb->bi_db_opflags );
+ text = NULL;
+ if( rc != 0 ) {
+ Debug( LDAP_DEBUG_TRACE,
+ "bdb_delete: txn_begin failed: %s (%d)\n",
+ db_strerror(rc), rc, 0 );
+ rc = LDAP_OTHER;
+ text = "internal error";
+ goto return_results;
}
opinfo.boi_bdb = be;
goto return_results;
}
- if( bdb->bi_txn ) {
- rc = txn_commit( ltid, 0 );
- }
+ rc = txn_commit( ltid, 0 );
ltid = NULL;
op->o_private = NULL;
ldap_pvt_thread_yield();
}
- if( bdb->bi_txn ) {
- /* begin transaction */
- rc = txn_begin( bdb->bi_dbenv, NULL, <id,
- bdb->bi_db_opflags );
- *text = NULL;
- if( rc != 0 ) {
- Debug( LDAP_DEBUG_TRACE,
- "bdb_exop_passwd: txn_begin failed: %s (%d)\n",
- db_strerror(rc), rc, 0 );
- rc = LDAP_OTHER;
- *text = "internal error";
- goto done;
- }
+ /* begin transaction */
+ rc = txn_begin( bdb->bi_dbenv, NULL, <id,
+ bdb->bi_db_opflags );
+ *text = NULL;
+ if( rc != 0 ) {
+ Debug( LDAP_DEBUG_TRACE,
+ "bdb_exop_passwd: txn_begin failed: %s (%d)\n",
+ db_strerror(rc), rc, 0 );
+ rc = LDAP_OTHER;
+ *text = "internal error";
+ goto done;
}
opinfo.boi_bdb = be;
rc = LDAP_OTHER;
}
- if( bdb->bi_txn && rc == 0 ) {
+ if( rc == 0 ) {
rc = txn_commit( ltid, 0 );
ltid = NULL;
}
Debug( LDAP_DEBUG_TRACE, "=> bdb_tool_entry_put( %ld, \"%s\" )\n",
(long) e->e_id, e->e_dn, 0 );
- if( bdb->bi_txn ) {
- rc = txn_begin( bdb->bi_dbenv, NULL, &tid,
- bdb->bi_db_opflags );
- if( rc != 0 ) {
- snprintf( text->bv_val, text->bv_len,
- "txn_begin failed: %s (%d)",
- db_strerror(rc), rc );
- Debug( LDAP_DEBUG_ANY,
- "=> bdb_tool_entry_put: %s\n",
- text->bv_val, 0, 0 );
- return NOID;
- }
+ rc = txn_begin( bdb->bi_dbenv, NULL, &tid,
+ bdb->bi_db_opflags );
+ if( rc != 0 ) {
+ snprintf( text->bv_val, text->bv_len,
+ "txn_begin failed: %s (%d)",
+ db_strerror(rc), rc );
+ Debug( LDAP_DEBUG_ANY,
+ "=> bdb_tool_entry_put: %s\n",
+ text->bv_val, 0, 0 );
+ return NOID;
}
rc = bdb_next_id( be, tid, &e->e_id );
}
done:
- if( bdb->bi_txn ) {
- if( rc == 0 ) {
- rc = txn_commit( tid, 0 );
- if( rc != 0 ) {
- snprintf( text->bv_val, text->bv_len,
- "txn_commit failed: %s (%d)",
- db_strerror(rc), rc );
- Debug( LDAP_DEBUG_ANY,
- "=> bdb_tool_entry_put: %s\n",
- text->bv_val, 0, 0 );
- e->e_id = NOID;
- }
-
- } else {
- txn_abort( tid );
+ if( rc == 0 ) {
+ rc = txn_commit( tid, 0 );
+ if( rc != 0 ) {
snprintf( text->bv_val, text->bv_len,
- "txn_aborted! %s (%d)",
+ "txn_commit failed: %s (%d)",
db_strerror(rc), rc );
Debug( LDAP_DEBUG_ANY,
"=> bdb_tool_entry_put: %s\n",
text->bv_val, 0, 0 );
e->e_id = NOID;
}
+
+ } else {
+ txn_abort( tid );
+ snprintf( text->bv_val, text->bv_len,
+ "txn_aborted! %s (%d)",
+ db_strerror(rc), rc );
+ Debug( LDAP_DEBUG_ANY,
+ "=> bdb_tool_entry_put: %s\n",
+ text->bv_val, 0, 0 );
+ e->e_id = NOID;
}
return e->e_id;
return -1;
}
- if( bi->bi_txn ) {
- rc = txn_begin( bi->bi_dbenv, NULL, &tid, bi->bi_db_opflags );
- if( rc != 0 ) {
- Debug( LDAP_DEBUG_ANY,
- "=> bdb_tool_entry_reindex: txn_begin failed: %s (%d)\n",
- db_strerror(rc), rc, 0 );
- goto done;
- }
+ rc = txn_begin( bi->bi_dbenv, NULL, &tid, bi->bi_db_opflags );
+ if( rc != 0 ) {
+ Debug( LDAP_DEBUG_ANY,
+ "=> bdb_tool_entry_reindex: txn_begin failed: %s (%d)\n",
+ db_strerror(rc), rc, 0 );
+ goto done;
}
/*
rc = bdb_index_entry_add( be, tid, e, e->e_attrs );
done:
- if( bi->bi_txn ) {
- if( rc == 0 ) {
- rc = txn_commit( tid, 0 );
- if( rc != 0 ) {
- Debug( LDAP_DEBUG_ANY,
- "=> bdb_tool_entry_reindex: txn_commit failed: %s (%d)\n",
- db_strerror(rc), rc, 0 );
- e->e_id = NOID;
- }
-
- } else {
- txn_abort( tid );
+ if( rc == 0 ) {
+ rc = txn_commit( tid, 0 );
+ if( rc != 0 ) {
Debug( LDAP_DEBUG_ANY,
- "=> bdb_tool_entry_reindex: txn_aborted! %s (%d)\n",
+ "=> bdb_tool_entry_reindex: txn_commit failed: %s (%d)\n",
db_strerror(rc), rc, 0 );
e->e_id = NOID;
}
+
+ } else {
+ txn_abort( tid );
+ Debug( LDAP_DEBUG_ANY,
+ "=> bdb_tool_entry_reindex: txn_aborted! %s (%d)\n",
+ db_strerror(rc), rc, 0 );
+ e->e_id = NOID;
}
return rc;