From ede8415d61b6791114c65de1c283a4e8c11f1585 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 22 Sep 2005 03:56:41 +0000 Subject: 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) --- source4/lib/ldb/ldb_tdb/ldb_tdb.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'source4/lib/ldb/ldb_tdb') 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 { -- cgit