diff options
author | Nick Mathewson <nickm@torproject.org> | 2018-04-02 15:02:53 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2018-04-13 10:44:15 -0400 |
commit | c5a3e2ca44cfd3302a65ae247120fd4efb81a379 (patch) | |
tree | 7ce3a789325311591148af0eec707eff74ef04ce /src/common/compat_libevent.h | |
parent | ad57b1279ab68e204243ddf3cf841fd85606c331 (diff) | |
download | tor-c5a3e2ca44cfd3302a65ae247120fd4efb81a379.tar.gz tor-c5a3e2ca44cfd3302a65ae247120fd4efb81a379.zip |
Generic mechaism for "post-loop" callbacks
We've been labeling some events as happening "outside the event
loop", to avoid Libevent starvation. This patch provides a cleaner
mechanism to avoid that starvation.
For background, the problem here is that Libevent only scans for new
events once it has run all its active callbacks. So if the
callbacks keep activating new callbacks, they could potentially
starve Libevent indefinitely and keep it from ever checking for
timed, socket, or signal events.
To solve this, we add the ability to label some events as
"post-loop". The rule for a "post-loop" event is that any events
_it_ activates can only be run after libevent has re-scanned for new
events at least once.
Diffstat (limited to 'src/common/compat_libevent.h')
-rw-r--r-- | src/common/compat_libevent.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/common/compat_libevent.h b/src/common/compat_libevent.h index c8b0371564..29c6ad375a 100644 --- a/src/common/compat_libevent.h +++ b/src/common/compat_libevent.h @@ -37,6 +37,9 @@ void periodic_timer_free_(periodic_timer_t *); typedef struct mainloop_event_t mainloop_event_t; mainloop_event_t *mainloop_event_new(void (*cb)(mainloop_event_t *, void *), void *userdata); +mainloop_event_t * mainloop_event_postloop_new( + void (*cb)(mainloop_event_t *, void *), + void *userdata); void mainloop_event_activate(mainloop_event_t *event); int mainloop_event_schedule(mainloop_event_t *event, const struct timeval *delay); |