From 2010d661dd2baacbc98dc5f54caf5e8aab522e62 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Sun, 22 Apr 2012 15:47:40 +0200 Subject: [PATCH] eloop: fix memory leak for shared signals A shared signal owns an eloop_fd object. This has a reference of its connected eloop. Therefore, we must free a shared signal to drop a reference to the connected eloop and cannot postpone this to eloop-destruction. Otherwise, the eloop will never get destroyed. Signed-off-by: David Herrmann --- src/eloop.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/eloop.c b/src/eloop.c index 3577cd2..8532588 100644 --- a/src/eloop.c +++ b/src/eloop.c @@ -578,6 +578,8 @@ void ev_eloop_unregister_signal_cb(struct ev_eloop *loop, int signum, sig = kmscon_dlist_entry(iter, struct ev_signal_shared, list); if (sig->signum == signum) { kmscon_hook_rm_cast(sig->hook, cb, data); + if (!kmscon_hook_num(sig->hook)) + signal_free(sig); return; } }