ctdb-client: Fix implementation of transaction cancel
authorAmitay Isaacs <amitay@gmail.com>
Fri, 1 Jul 2016 07:53:17 +0000 (17:53 +1000)
committerMartin Schwenke <martins@samba.org>
Tue, 5 Jul 2016 08:53:15 +0000 (10:53 +0200)
Wrap async transaction cancel to unlock g_lock lock and free transaction
handle.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
ctdb/client/client_db.c

index c1c77124abcaf9286159e3ea677a9b40fd49698e..8bfd3f08f034d8f6355d72584ad494cce0df91be 100644 (file)
@@ -2234,7 +2234,33 @@ bool ctdb_transaction_cancel_recv(struct tevent_req *req, int *perr)
 
 int ctdb_transaction_cancel(struct ctdb_transaction_handle *h)
 {
-       talloc_free(h);
+       struct tevent_context *ev = h->ev;
+       struct tevent_req *req;
+       TALLOC_CTX *mem_ctx;
+       int ret;
+       bool status;
+
+       mem_ctx = talloc_new(NULL);
+       if (mem_ctx == NULL) {
+               return ENOMEM;
+       }
+
+       req = ctdb_transaction_cancel_send(mem_ctx, ev,
+                                          tevent_timeval_zero(), h);
+       if (req == NULL) {
+               talloc_free(mem_ctx);
+               return ENOMEM;
+       }
+
+       tevent_req_poll(req, ev);
+
+       status = ctdb_transaction_cancel_recv(req, &ret);
+       if (! status) {
+               talloc_free(mem_ctx);
+               return ret;
+       }
+
+       talloc_free(mem_ctx);
        return 0;
 }