From 11331eeae59699911520c9e0284f45c5f3704e01 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 8 Aug 2008 16:44:24 +1000 Subject: 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) --- source3/lib/dbwrap_ctdb.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'source3') 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; -- cgit