summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2008-08-08 16:44:24 +1000
committerMichael Adam <obnox@samba.org>2008-08-13 11:54:11 +0200
commit11331eeae59699911520c9e0284f45c5f3704e01 (patch)
treefb1ce4747a32ebea17cbd01dd2705526ff18e245 /source3/lib
parentd9a21089b3f422998d229940b535c0d96dfdeabc (diff)
downloadsamba-11331eeae59699911520c9e0284f45c5f3704e01.tar.gz
samba-11331eeae59699911520c9e0284f45c5f3704e01.tar.bz2
samba-11331eeae59699911520c9e0284f45c5f3704e01.zip
allow nested ctdb transactions in the same manner that they are
allowed for tdb. This is needed for the registry db backend. (This used to be commit 4b04ec29c76df837a7909725bbbf4c79d5abdb4d)
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/dbwrap_ctdb.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/source3/lib/dbwrap_ctdb.c b/source3/lib/dbwrap_ctdb.c
index 541b278970..7c1ef8fed8 100644
--- a/source3/lib/dbwrap_ctdb.c
+++ b/source3/lib/dbwrap_ctdb.c
@@ -31,6 +31,8 @@ struct db_ctdb_transaction_handle {
*/
struct ctdb_marshall_buffer *m_all;
struct ctdb_marshall_buffer *m_write;
+ uint32_t nesting;
+ bool nested_cancel;
};
struct db_ctdb_ctx {
@@ -279,8 +281,8 @@ static int db_ctdb_transaction_start(struct db_context *db)
}
if (ctx->transaction) {
- DEBUG(0,("Nested transactions not supported on db 0x%08x\n", ctx->db_id));
- return -1;
+ ctx->transaction->nesting++;
+ return 0;
}
h = talloc_zero(db, struct db_ctdb_transaction_handle);
@@ -616,6 +618,17 @@ static int db_ctdb_transaction_commit(struct db_context *db)
return -1;
}
+ if (h->nested_cancel) {
+ db->transaction_cancel(db);
+ DEBUG(5,(__location__ " Failed transaction commit after nested cancel\n"));
+ return -1;
+ }
+
+ if (h->nesting != 0) {
+ h->nesting--;
+ return 0;
+ }
+
DEBUG(5,(__location__ " Commit transaction on db 0x%08x\n", ctx->db_id));
talloc_set_destructor(h, NULL);
@@ -734,6 +747,12 @@ static int db_ctdb_transaction_cancel(struct db_context *db)
return -1;
}
+ if (h->nesting != 0) {
+ h->nesting--;
+ h->nested_cancel = true;
+ return 0;
+ }
+
DEBUG(5,(__location__ " Cancel transaction on db 0x%08x\n", ctx->db_id));
ctx->transaction = NULL;