diff options
author | Nick Mathewson <nickm@torproject.org> | 2011-09-09 20:53:30 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2011-09-09 20:57:54 -0400 |
commit | 4e8eb6a59549e82468d0aa6fbd0fa351e7e5d1fb (patch) | |
tree | 99660f4a4667a0f37d9746059c88b222d144adb1 /event.c | |
parent | f72e8f6643992e4369eba64fb4c6e48e119086e4 (diff) | |
download | libevent-4e8eb6a59549e82468d0aa6fbd0fa351e7e5d1fb.tar.gz |
When a signal callback is activated to run multiple times, allow event_base_loopbreak to work even before they all have run.
Found by Abilio Marques.
Diffstat (limited to 'event.c')
-rw-r--r-- | event.c | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -1024,6 +1024,7 @@ static inline void event_signal_closure(struct event_base *base, struct event *ev) { short ncalls; + int should_break; /* Allows deletes to work */ ncalls = ev->ev_ncalls; @@ -1035,11 +1036,13 @@ event_signal_closure(struct event_base *base, struct event *ev) if (ncalls == 0) ev->ev_pncalls = NULL; (*ev->ev_callback)((int)ev->ev_fd, ev->ev_res, ev->ev_arg); -#if 0 - /* XXXX we can't do this without a lock on the base. */ - if (base->event_break) + + EVBASE_ACQUIRE_LOCK(base, th_base_lock); + should_break = base->event_break; + EVBASE_RELEASE_LOCK(base, th_base_lock); + + if (should_break) return; -#endif } } |