Fix a list corruption bug when using event_reinit() with signals present

While re-adding all the events, event_reinit() could add a signal
event, which could then cause evsig_add() to add the
base->sig.ev_signal event.  Later on its merry path through
base->eventqueue, event_reinit() would find that same event and give
it to event_io_add a second time.  This would make the ev_io_next
list for that fd become circular.  Ouch!
This commit is contained in:
Nick Mathewson 2012-01-23 17:59:16 -05:00
parent 3312b02036
commit 6e41cdc16b

View File

@ -856,6 +856,13 @@ event_reinit(struct event_base *base)
TAILQ_FOREACH(ev, &base->eventqueue, ev_next) {
if (ev->ev_events & (EV_READ|EV_WRITE)) {
if (ev == &base->sig.ev_signal) {
/* If we run into the ev_signal event, it's only
* in eventqueue because some signal event was
* added, which made evsig_add re-add ev_signal.
* So don't double-add it. */
continue;
}
if (evmap_io_add(base, ev->ev_fd, ev) == -1)
res = -1;
} else if (ev->ev_events & EV_SIGNAL) {