diff options
author | Ronnie Sahlberg <ronniesahlberg@gmail.com> | 2009-04-26 08:38:37 +1000 |
---|---|---|
committer | Ronnie Sahlberg <ronniesahlberg@gmail.com> | 2009-04-26 08:38:37 +1000 |
commit | 777c634eae5944b9987e560b64f6cdd39a473c71 (patch) | |
tree | a29ae4d9d660faa2b0be8f060da4f0f1f3c7751e /ctdb | |
parent | 38ea6708dd16f88966ae5157fe523f4758317186 (diff) | |
download | samba-777c634eae5944b9987e560b64f6cdd39a473c71.tar.gz samba-777c634eae5944b9987e560b64f6cdd39a473c71.tar.xz samba-777c634eae5944b9987e560b64f6cdd39a473c71.zip |
add TDB_NO_NESTING. When this flag is set tdb will not allow any nested transactions and tdb_transaction_start() will implicitely _cancel() any pending transactions before starting any new ones.
(This used to be ctdb commit 459e4ee135bd1cd24c15e5325906eb4ecfd550ec)
Diffstat (limited to 'ctdb')
-rw-r--r-- | ctdb/lib/tdb/common/transaction.c | 18 | ||||
-rw-r--r-- | ctdb/lib/tdb/include/tdb.h | 1 |
2 files changed, 15 insertions, 4 deletions
diff --git a/ctdb/lib/tdb/common/transaction.c b/ctdb/lib/tdb/common/transaction.c index 4e2127be64..6a34c45269 100644 --- a/ctdb/lib/tdb/common/transaction.c +++ b/ctdb/lib/tdb/common/transaction.c @@ -85,6 +85,11 @@ still available, but no transaction recovery area is used and no fsync/msync calls are made. + - if TDB_NO_NESTING is passed to flags in tdb open then transaction + nesting is disabled. tdb_transaction_start() will then implicitely + cancel any pending transactions and always start a new transaction + context instead of nesting. + */ @@ -409,10 +414,15 @@ int tdb_transaction_start(struct tdb_context *tdb) /* cope with nested tdb_transaction_start() calls */ if (tdb->transaction != NULL) { - tdb->transaction->nesting++; - TDB_LOG((tdb, TDB_DEBUG_TRACE, "tdb_transaction_start: nesting %d\n", - tdb->transaction->nesting)); - return 0; + if (!tdb->flags & TDB_NO_NESTING) { + tdb->transaction->nesting++; + TDB_LOG((tdb, TDB_DEBUG_TRACE, "tdb_transaction_start: nesting %d\n", + tdb->transaction->nesting)); + return 0; + } else { + tdb_transaction_cancel(tdb); + TDB_LOG((tdb, TDB_DEBUG_TRACE, "tdb_transaction_start: cancelling previous transaction\n")); + } } if (tdb->num_locks != 0 || tdb->global_lock.count) { diff --git a/ctdb/lib/tdb/include/tdb.h b/ctdb/lib/tdb/include/tdb.h index 0008085de5..628118172e 100644 --- a/ctdb/lib/tdb/include/tdb.h +++ b/ctdb/lib/tdb/include/tdb.h @@ -47,6 +47,7 @@ extern "C" { #define TDB_NOSYNC 64 /* don't use synchronous transactions */ #define TDB_SEQNUM 128 /* maintain a sequence number */ #define TDB_VOLATILE 256 /* Activate the per-hashchain freelist, default 5 */ +#define TDB_NO_NESTING 512 /* Dont allow transaction nesting */ #define TDB_ERRCODE(code, ret) ((tdb->ecode = (code)), ret) |