From 819cdee9a7c6cda98d559bbeda999eda49d0afe9 Mon Sep 17 00:00:00 2001 From: Amitay Isaacs Date: Fri, 5 Aug 2016 13:10:28 +1000 Subject: [PATCH 1/2] ctdb-client: transaction_cancel must free transaction handle BUG: https://bugzilla.samba.org/show_bug.cgi?id=12122 Signed-off-by: Amitay Isaacs Reviewed-by: Martin Schwenke (cherry picked from commit 8aa00035faeb307c061dc20e62a0ace7f2a1413b) --- ctdb/client/client_db.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ctdb/client/client_db.c b/ctdb/client/client_db.c index 98de1b8..794119d 100644 --- a/ctdb/client/client_db.c +++ b/ctdb/client/client_db.c @@ -2304,6 +2304,7 @@ static void ctdb_transaction_cancel_done(struct tevent_req *subreq) DEBUG(DEBUG_ERR, ("transaction_cancel: %s g_lock unlock failed, ret=%d\n", state->h->db->db_name, ret)); + talloc_free(state->h); tevent_req_error(req, ret); return; } @@ -2336,6 +2337,7 @@ int ctdb_transaction_cancel(struct ctdb_transaction_handle *h) mem_ctx = talloc_new(NULL); if (mem_ctx == NULL) { + talloc_free(h); return ENOMEM; } @@ -2343,6 +2345,7 @@ int ctdb_transaction_cancel(struct ctdb_transaction_handle *h) tevent_timeval_zero(), h); if (req == NULL) { talloc_free(mem_ctx); + talloc_free(h); return ENOMEM; } -- 2.8.1 From 94655a4b79685887c5a1288de8fe2dae75f4d94f Mon Sep 17 00:00:00 2001 From: Amitay Isaacs Date: Fri, 5 Aug 2016 13:13:08 +1000 Subject: [PATCH 2/2] ctdb-tools: Cancel transaction on error or if commit fails BUG: https://bugzilla.samba.org/show_bug.cgi?id=12122 Signed-off-by: Amitay Isaacs Reviewed-by: Martin Schwenke (cherry picked from commit 4d144d7106d56bbb48669dd35eb324377dd09b59) --- ctdb/tools/ctdb.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ctdb/tools/ctdb.c b/ctdb/tools/ctdb.c index c83d397..eba6cdd 100644 --- a/ctdb/tools/ctdb.c +++ b/ctdb/tools/ctdb.c @@ -5136,6 +5136,7 @@ static int control_pfetch(TALLOC_CTX *mem_ctx, struct ctdb_context *ctdb, if (ret != 0) { fprintf(stderr, "Failed to read record for key %s\n", argv[1]); + ctdb_transaction_cancel(h); return ret; } @@ -5200,6 +5201,7 @@ static int control_pstore(TALLOC_CTX *mem_ctx, struct ctdb_context *ctdb, if (ret != 0) { fprintf(stderr, "Failed to store record for key %s\n", argv[1]); + ctdb_transaction_cancel(h); return ret; } @@ -5207,6 +5209,7 @@ static int control_pstore(TALLOC_CTX *mem_ctx, struct ctdb_context *ctdb, if (ret != 0) { fprintf(stderr, "Failed to commit transaction on db %s\n", db_name); + ctdb_transaction_cancel(h); return ret; } @@ -5262,6 +5265,7 @@ static int control_pdelete(TALLOC_CTX *mem_ctx, struct ctdb_context *ctdb, if (ret != 0) { fprintf(stderr, "Failed to delete record for key %s\n", argv[1]); + ctdb_transaction_cancel(h); return ret; } @@ -5269,6 +5273,7 @@ static int control_pdelete(TALLOC_CTX *mem_ctx, struct ctdb_context *ctdb, if (ret != 0) { fprintf(stderr, "Failed to commit transaction on db %s\n", db_name); + ctdb_transaction_cancel(h); return ret; } @@ -5412,6 +5417,7 @@ static int control_ptrans(TALLOC_CTX *mem_ctx, struct ctdb_context *ctdb, if (ret != 0) { fprintf(stderr, "Failed to commit transaction on db %s\n", db_name); + ctdb_transaction_cancel(h); } done: -- 2.8.1