summaryrefslogtreecommitdiff
path: root/ctdb
diff options
context:
space:
mode:
authorAmitay Isaacs <amitay@gmail.com>2017-10-19 14:58:18 +1100
committerKarolin Seeger <kseeger@samba.org>2017-11-22 09:48:18 +0100
commitc54477d9bf4006156b261c374c0071ba87d6c03d (patch)
tree0d9ff96bf8b7988a68a9c679f7a0b3085aef37ed /ctdb
parent7e41c947641d3ec52174c9780b79e39871fd11be (diff)
downloadsamba-c54477d9bf4006156b261c374c0071ba87d6c03d.tar.gz
ctdb-daemon: Allocate deferred calls off calling context
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13152 This makes sure that if a client disconnects, all the deferred calls from the client are correctly freed. Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net> (cherry picked from commit 848f2425984667c243ccac847b8f48a66ce10178)
Diffstat (limited to 'ctdb')
-rw-r--r--ctdb/server/ctdb_call.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/ctdb/server/ctdb_call.c b/ctdb/server/ctdb_call.c
index b3bc9cf7476..a4f84a34a86 100644
--- a/ctdb/server/ctdb_call.c
+++ b/ctdb/server/ctdb_call.c
@@ -1567,6 +1567,7 @@ struct revokechild_deferred_call {
struct ctdb_req_header *hdr;
deferred_requeue_fn fn;
void *ctx;
+ struct revokechild_handle *rc;
};
struct revokechild_handle {
@@ -1591,12 +1592,20 @@ static void deferred_call_requeue(struct tevent_context *ev,
while (dlist != NULL) {
struct revokechild_deferred_call *dcall = dlist;
+ talloc_set_destructor(dcall, NULL);
DLIST_REMOVE(dlist, dcall);
dcall->fn(dcall->ctx, dcall->hdr);
talloc_free(dcall);
}
}
+static int deferred_call_destructor(struct revokechild_deferred_call *dcall)
+{
+ struct revokechild_handle *rc = dcall->rc;
+
+ DLIST_REMOVE(rc->deferred_call_list, dcall);
+ return 0;
+}
static int revokechild_destructor(struct revokechild_handle *rc)
{
@@ -1935,7 +1944,7 @@ int ctdb_add_revoke_deferred_call(struct ctdb_context *ctdb, struct ctdb_db_cont
return -1;
}
- deferred_call = talloc(ctdb_db, struct revokechild_deferred_call);
+ deferred_call = talloc(call_context, struct revokechild_deferred_call);
if (deferred_call == NULL) {
DEBUG(DEBUG_ERR,("Failed to allocate deferred call structure for revoking record\n"));
return -1;
@@ -1945,6 +1954,9 @@ int ctdb_add_revoke_deferred_call(struct ctdb_context *ctdb, struct ctdb_db_cont
deferred_call->hdr = talloc_steal(deferred_call, hdr);
deferred_call->fn = fn;
deferred_call->ctx = call_context;
+ deferred_call->rc = rc;
+
+ talloc_set_destructor(deferred_call, deferred_call_destructor);
DLIST_ADD(rc->deferred_call_list, deferred_call);