mirror of
https://github.com/libevent/libevent.git
synced 2025-01-31 09:12:55 +08:00
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:
parent
3312b02036
commit
6e41cdc16b
7
event.c
7
event.c
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user