summaryrefslogtreecommitdiff
path: root/source4/lib/ldb/ldb_tdb
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-09-22 03:56:41 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:38:41 -0500
commitede8415d61b6791114c65de1c283a4e8c11f1585 (patch)
treef57fed9af4459d650db40546527ba230382a3248 /source4/lib/ldb/ldb_tdb
parentd6de10b409329084075c59d9371695871c738362 (diff)
downloadsamba-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/ldb_tdb')
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_tdb.c24
1 files changed, 22 insertions, 2 deletions
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 {