]> granicus.if.org Git - libevent/commitdiff
event_reinit: make signals works after fork() without evsig_add()
authorNicholas Marriott <@nicm>
Sat, 26 Dec 2015 23:15:03 +0000 (02:15 +0300)
committerAzat Khuzhin <a3at.mail@gmail.com>
Sat, 26 Dec 2015 23:51:43 +0000 (02:51 +0300)
event_reinit() removes the event, but only evsig_add puts it back. So any
signals set up before event_reinit will be ignored until another signal is
added.

Fixes: #307
event.c

diff --git a/event.c b/event.c
index 082d292f0e8203648ff5d92166aa491cec2993a6..503003e249a29909465e05421ed865c772e4648c 100644 (file)
--- a/event.c
+++ b/event.c
@@ -1025,6 +1025,11 @@ event_reinit(struct event_base *base)
                        res = -1;
        } else {
                res = evsig_init_(base);
+               if (res == 0 && had_signal_added) {
+                       res = event_add_nolock_(&base->sig.ev_signal, NULL, 0);
+                       if (res == 0)
+                               base->sig.ev_signal_added = 1;
+               }
        }
 
        /* If we were notifiable before, and nothing just exploded, become