From 0ede290b3a509f0ff02058ed73cba564c82405c1 Mon Sep 17 00:00:00 2001 From: Niels Provos Date: Mon, 19 Jan 2009 23:42:19 +0000 Subject: [PATCH] from trunk: bug fix and potentital race condition from Alexander Drozdov svn:r1026 --- event.c | 5 +++++ signal.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/event.c b/event.c index 63802083..ae6c36e6 100644 --- a/event.c +++ b/event.c @@ -285,8 +285,13 @@ event_reinit(struct event_base *base) /* prevent internal delete */ if (base->sig.ev_signal_added) { + /* we cannot call event_del here because the base has + * not been reinitialized yet. */ event_queue_remove(base, &base->sig.ev_signal, EVLIST_INSERTED); + if (base->sig.ev_signal.ev_flags & EVLIST_ACTIVE) + event_queue_remove(base, &base->sig.ev_signal, + EVLIST_ACTIVE); base->sig.ev_signal_added = 0; } diff --git a/signal.c b/signal.c index bcaa3f9b..c014ea74 100644 --- a/signal.c +++ b/signal.c @@ -310,6 +310,7 @@ evsignal_process(struct event_base *base) ncalls = sig->evsigcaught[i]; if (ncalls == 0) continue; + sig->evsigcaught[i] -= ncalls; for (ev = TAILQ_FIRST(&sig->evsigevents[i]); ev != NULL; ev = next_ev) { @@ -319,7 +320,6 @@ evsignal_process(struct event_base *base) event_active(ev, EV_SIGNAL, ncalls); } - sig->evsigcaught[i] = 0; } }