diff options
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 { |