diff options
author | Andrew Tridgell <tridge@samba.org> | 2005-09-22 03:56:41 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:38:41 -0500 |
commit | ede8415d61b6791114c65de1c283a4e8c11f1585 (patch) | |
tree | f57fed9af4459d650db40546527ba230382a3248 /source4/lib/ldb | |
parent | d6de10b409329084075c59d9371695871c738362 (diff) | |
download | samba-ede8415d61b6791114c65de1c283a4e8c11f1585.tar.gz samba-ede8415d61b6791114c65de1c283a4e8c11f1585.tar.bz2 samba-ede8415d61b6791114c65de1c283a4e8c11f1585.zip |
r10405: added transactions into tdb, and hook them into ldb. See my
samba-technical posting for more details on the transactions design.
This also adds a number of command line arguments to tdbtorture,
making it more flexible, and fixes some lock deadlock conditions in
the tdbtorture code.
(This used to be commit 06bd8abba942ec9f1e23f5c5d546cbb71ca3a701)
Diffstat (limited to 'source4/lib/ldb')
-rw-r--r-- | source4/lib/ldb/Makefile.in | 3 | ||||
-rw-r--r-- | source4/lib/ldb/configure.in | 1 | ||||
-rw-r--r-- | source4/lib/ldb/ldb_tdb/ldb_tdb.c | 24 |
3 files changed, 25 insertions, 3 deletions
diff --git a/source4/lib/ldb/Makefile.in b/source4/lib/ldb/Makefile.in index b40933bc0d..2ffe6d25b8 100644 --- a/source4/lib/ldb/Makefile.in +++ b/source4/lib/ldb/Makefile.in @@ -44,7 +44,8 @@ LIB_FLAGS=-Llib -lldb $(LDAP_LIBS) $(SQLITE3_LIBS) $(GCOV_LIBS) @LIBS@ TDB_OBJ=$(TDBDIR)/common/tdb.o $(TDBDIR)/common/dump.o \ $(TDBDIR)/common/io.o $(TDBDIR)/common/lock.o \ $(TDBDIR)/common/open.o $(TDBDIR)/common/traverse.o \ - $(TDBDIR)/common/freelist.o $(TDBDIR)/common/error.o + $(TDBDIR)/common/freelist.o $(TDBDIR)/common/error.o \ + $(TDBDIR)/common/transaction.o TALLOC_OBJ=$(TALLOCDIR)/talloc.o LDB_TDB_OBJ=ldb_tdb/ldb_tdb.o \ diff --git a/source4/lib/ldb/configure.in b/source4/lib/ldb/configure.in index 7ae339c103..8b9e599892 100644 --- a/source4/lib/ldb/configure.in +++ b/source4/lib/ldb/configure.in @@ -34,4 +34,5 @@ WITH_SQLITE3=$with_sqlite3_support AC_SUBST(WITH_SQLITE3) sinclude(config.m4) sinclude(../talloc/config.m4) +sinclude(../tdb/config.m4) AC_OUTPUT(Makefile ldb.pc) diff --git a/source4/lib/ldb/ldb_tdb/ldb_tdb.c b/source4/lib/ldb/ldb_tdb/ldb_tdb.c index 265e04a057..c056bd2e2d 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_tdb.c +++ b/source4/lib/ldb/ldb_tdb/ldb_tdb.c @@ -833,14 +833,28 @@ failed: static int ltdb_start_trans(struct ldb_module *module) { - /* TODO: implement transactions */ + struct ltdb_private *ltdb = module->private_data; + + if (tdb_transaction_start(ltdb->tdb) != 0) { + return LDB_ERR_OPERATIONS_ERROR; + } return LDB_ERR_SUCCESS; } static int ltdb_end_trans(struct ldb_module *module, int status) { - /* TODO: implement transactions */ + struct ltdb_private *ltdb = module->private_data; + + if (status != LDB_ERR_SUCCESS) { + if (tdb_transaction_cancel(ltdb->tdb) != 0) { + return LDB_ERR_OPERATIONS_ERROR; + } + } else { + if (tdb_transaction_commit(ltdb->tdb) != 0) { + return LDB_ERR_OPERATIONS_ERROR; + } + } return status; } @@ -881,6 +895,12 @@ int ltdb_connect(struct ldb_context *ldb, const char *url, tdb_flags = TDB_DEFAULT; +#if 0 + /* set this to run tdb without disk sync, but still with + transactions */ + tdb_flags |= TDB_NOSYNC; +#endif + if (flags & LDB_FLG_RDONLY) { open_flags = O_RDONLY; } else { |