summaryrefslogtreecommitdiff
path: root/event.c
diff options
context:
space:
mode:
authorNicholas Marriott <@nicm>2015-12-27 01:43:37 +0300
committerAzat Khuzhin <a3at.mail@gmail.com>2015-12-27 02:51:24 +0300
commitad0c237bc0b2edd4f1dc0e82c6cffbde71bad78b (patch)
tree54faf187e1e7f049b0b5e2c905a91ae2a3345ec0 /event.c
parentb8ec70c461b0b3d3d9fc4f1a3d28cce8d05354dc (diff)
downloadlibevent-ad0c237bc0b2edd4f1dc0e82c6cffbde71bad78b.tar.gz
event_reinit: always re-init signal's socketpair
Before this patch event_reinit() only closes the signal socketpair fds and recreates them if signals have been added, but this is wrong, since socketpair fds created on backend init, and if we will not re-create them bad things in child/parent signal handling will happens (and indeed this is what happens for non-reinit backends like select). Fixes: #307
Diffstat (limited to 'event.c')
-rw-r--r--event.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/event.c b/event.c
index def17665..082d292f 100644
--- a/event.c
+++ b/event.c
@@ -969,13 +969,13 @@ event_reinit(struct event_base *base)
event_del_nolock_(&base->sig.ev_signal, EVENT_DEL_AUTOBLOCK);
event_debug_unassign(&base->sig.ev_signal);
memset(&base->sig.ev_signal, 0, sizeof(base->sig.ev_signal));
- if (base->sig.ev_signal_pair[0] != -1)
- EVUTIL_CLOSESOCKET(base->sig.ev_signal_pair[0]);
- if (base->sig.ev_signal_pair[1] != -1)
- EVUTIL_CLOSESOCKET(base->sig.ev_signal_pair[1]);
had_signal_added = 1;
base->sig.ev_signal_added = 0;
}
+ if (base->sig.ev_signal_pair[0] != -1)
+ EVUTIL_CLOSESOCKET(base->sig.ev_signal_pair[0]);
+ if (base->sig.ev_signal_pair[1] != -1)
+ EVUTIL_CLOSESOCKET(base->sig.ev_signal_pair[1]);
if (base->th_notify_fn != NULL) {
was_notifiable = 1;
base->th_notify_fn = NULL;
@@ -1024,8 +1024,7 @@ event_reinit(struct event_base *base)
if (evmap_reinit_(base) < 0)
res = -1;
} else {
- if (had_signal_added)
- res = evsig_init_(base);
+ res = evsig_init_(base);
}
/* If we were notifiable before, and nothing just exploded, become