From: Howard Chu Date: Mon, 24 Jan 2005 01:37:38 +0000 (+0000) Subject: Omit transaction support when running with SLAP_TOOL_QUICK X-Git-Tag: OPENLDAP_REL_ENG_2_3_BP~273 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=b674e6dd3d890dc7ecda9e91cd691fb1f51d7b93;p=openldap Omit transaction support when running with SLAP_TOOL_QUICK --- diff --git a/servers/slapd/back-bdb/back-bdb.h b/servers/slapd/back-bdb/back-bdb.h index d788665c3c..44517010fb 100644 --- a/servers/slapd/back-bdb/back-bdb.h +++ b/servers/slapd/back-bdb/back-bdb.h @@ -241,7 +241,7 @@ struct bdb_op_info { #if DB_VERSION_FULL >= 0x04010011 #undef DB_OPEN #define DB_OPEN(db, file, name, type, flags, mode) \ - (db)->open(db, NULL, file, name, type, (flags)|DB_AUTO_COMMIT, mode) + (db)->open(db, NULL, file, name, type, flags, mode) #endif #endif diff --git a/servers/slapd/back-bdb/dbcache.c b/servers/slapd/back-bdb/dbcache.c index adcdf463a7..3885b4c09a 100644 --- a/servers/slapd/back-bdb/dbcache.c +++ b/servers/slapd/back-bdb/dbcache.c @@ -63,7 +63,7 @@ bdb_db_cache( const char *name, DB **dbout ) { - int i; + int i, flags; int rc; struct bdb_info *bdb = (struct bdb_info *) be->be_private; struct bdb_db_info *db; @@ -118,11 +118,15 @@ bdb_db_cache( #ifdef HAVE_EBCDIC __atoe( file ); +#endif + flags = DB_CREATE | DB_THREAD; +#ifdef DB_AUTO_COMMIT + if ( !( slapMode & SLAP_TOOL_QUICK )) + flags |= DB_AUTO_COMMIT; #endif rc = DB_OPEN( db->bdi_db, file, NULL /* name */, - BDB_INDEXTYPE, bdb->bi_db_opflags | DB_CREATE | DB_THREAD, - bdb->bi_dbenv_mode ); + BDB_INDEXTYPE, bdb->bi_db_opflags | flags, bdb->bi_dbenv_mode ); ch_free( file ); diff --git a/servers/slapd/back-bdb/init.c b/servers/slapd/back-bdb/init.c index 188464e42a..cb5616bd2c 100644 --- a/servers/slapd/back-bdb/init.c +++ b/servers/slapd/back-bdb/init.c @@ -138,8 +138,10 @@ bdb_db_open( BackendDB *be ) return rc; } - flags = DB_INIT_MPOOL | DB_THREAD | DB_CREATE - | DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_TXN; + flags = DB_INIT_MPOOL | DB_THREAD | DB_CREATE | DB_INIT_LOCK; + +if ( !( slapMode & SLAP_TOOL_QUICK )) + flags |= DB_INIT_LOG | DB_INIT_TXN; #if 0 /* Never do automatic recovery, must perform it manually. @@ -273,6 +275,11 @@ bdb_db_open( BackendDB *be ) flags = DB_THREAD | bdb->bi_db_opflags; +#ifdef DB_AUTO_COMMIT + if ( !( slapMode & SLAP_TOOL_QUICK )) + flags |= DB_AUTO_COMMIT; +#endif + bdb->bi_databases = (struct bdb_db_info **) ch_malloc( BDB_INDICES * sizeof(struct bdb_db_info *) ); diff --git a/servers/slapd/back-bdb/tools.c b/servers/slapd/back-bdb/tools.c index f65d4b99d4..395c57e55e 100644 --- a/servers/slapd/back-bdb/tools.c +++ b/servers/slapd/back-bdb/tools.c @@ -307,6 +307,7 @@ ID bdb_tool_entry_put( Debug( LDAP_DEBUG_TRACE, "=> " LDAP_XSTRING(bdb_tool_entry_put) "( %ld, \"%s\" )\n", (long) e->e_id, e->e_dn, 0 ); + if (! (slapMode & SLAP_TOOL_QUICK)) { rc = TXN_BEGIN( bdb->bi_dbenv, NULL, &tid, bdb->bi_db_opflags ); if( rc != 0 ) { @@ -318,6 +319,7 @@ ID bdb_tool_entry_put( text->bv_val, 0, 0 ); return NOID; } + } op.o_hdr = &ohdr; op.o_bd = be; @@ -356,6 +358,7 @@ ID bdb_tool_entry_put( done: if( rc == 0 ) { + if ( !( slapMode & SLAP_TOOL_QUICK )) { rc = TXN_COMMIT( tid, 0 ); if( rc != 0 ) { snprintf( text->bv_val, text->bv_len, @@ -366,8 +369,10 @@ done: text->bv_val, 0, 0 ); e->e_id = NOID; } + } } else { + if ( !( slapMode & SLAP_TOOL_QUICK )) { TXN_ABORT( tid ); snprintf( text->bv_val, text->bv_len, "txn_aborted! %s (%d)", @@ -375,6 +380,7 @@ done: Debug( LDAP_DEBUG_ANY, "=> " LDAP_XSTRING(bdb_tool_entry_put) ": %s\n", text->bv_val, 0, 0 ); + } e->e_id = NOID; }