From: Andrew Tridgell Date: Fri, 8 Aug 2008 06:44:24 +0000 (+1000) Subject: allow nested ctdb transactions in the same manner that they are X-Git-Tag: samba-3.3.0pre1~134 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4b04ec29c76df837a7909725bbbf4c79d5abdb4d;p=thirdparty%2Fsamba.git allow nested ctdb transactions in the same manner that they are allowed for tdb. This is needed for the registry db backend. --- diff --git a/source/lib/dbwrap_ctdb.c b/source/lib/dbwrap_ctdb.c index 541b2789707..7c1ef8fed86 100644 --- a/source/lib/dbwrap_ctdb.c +++ b/source/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;