]> granicus.if.org Git - libevent/commitdiff
bug fix and potentital race condition from Alexander Drozdov
authorNiels Provos <provos@gmail.com>
Mon, 19 Jan 2009 23:40:11 +0000 (23:40 +0000)
committerNiels Provos <provos@gmail.com>
Mon, 19 Jan 2009 23:40:11 +0000 (23:40 +0000)
svn:r1025

event.c
signal.c

diff --git a/event.c b/event.c
index bc9e88b2d0884da0906008d54d2a36547224e963..4a577b9da034f2ecb79a7582e12cec38c93acd08 100644 (file)
--- a/event.c
+++ b/event.c
@@ -390,8 +390,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;
        }
        
index 4cbacd4c191a0731cbef44d8af7826ff42e11e75..2ceed2f3aad6ee05ac38dbc202bb262ad8f7fe73 100644 (file)
--- a/signal.c
+++ b/signal.c
@@ -311,9 +311,9 @@ evsig_process(struct event_base *base)
                ncalls = sig->evsigcaught[i];
                if (ncalls == 0)
                        continue;
+               sig->evsigcaught[i] -= ncalls;
 
                evmap_signal_active(base, i, ncalls);
-               sig->evsigcaught[i] = 0;
        }
 }