From 3f3eb4f63686ff8de94a1e6927b4413795c11d48 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 14 May 2007 14:01:33 +1000 Subject: [PATCH] we must not free the fde until after we no longer need the lock child (This used to be ctdb commit e06776c7c37b63f5c3165c7043d665e0c1a95337) --- ctdb/common/ctdb_lockwait.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ctdb/common/ctdb_lockwait.c b/ctdb/common/ctdb_lockwait.c index 22cff9d6b54..666da866e4e 100644 --- a/ctdb/common/ctdb_lockwait.c +++ b/ctdb/common/ctdb_lockwait.c @@ -51,14 +51,17 @@ static void lockwait_handler(struct event_context *ev, struct fd_event *fde, struct tdb_context *tdb = h->ctdb_db->ltdb->tdb; TALLOC_CTX *tmp_ctx = talloc_new(ev); - talloc_free(fde); - key.dptr = talloc_memdup(tmp_ctx, key.dptr, key.dsize); talloc_set_destructor(h, NULL); ctdb_latency(&h->ctdb->status.max_lockwait_latency, h->start_time); h->ctdb->status.pending_lockwait_calls--; + /* the fde needs to go away when the context is gone - when + the fde goes away this implicitly closes the pipe, which + kills the child holding the lock */ + talloc_steal(tmp_ctx, fde); + tdb_chainlock_mark(tdb, key); callback(p); tdb_chainlock_unmark(tdb, key);