]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
we must not free the fde until after we no longer need the lock child
authorAndrew Tridgell <tridge@samba.org>
Mon, 14 May 2007 04:01:33 +0000 (14:01 +1000)
committerAndrew Tridgell <tridge@samba.org>
Mon, 14 May 2007 04:01:33 +0000 (14:01 +1000)
(This used to be ctdb commit e06776c7c37b63f5c3165c7043d665e0c1a95337)

ctdb/common/ctdb_lockwait.c

index 22cff9d6b54707bfbffa15acb27939acdbb3b834..666da866e4ec5c3f082ba2a620aff666e355bc16 100644 (file)
@@ -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);