diff options
author | Nick Mathewson <nickm@torproject.org> | 2017-10-03 11:20:59 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2018-04-05 12:36:27 -0400 |
commit | b3586629c9ce41393898b381159ba331906f8fc3 (patch) | |
tree | df515c0311ce74f29890b77311403905aa406f55 | |
parent | 39cb04335f9fd5c3268c808bac549f531fe389a3 (diff) | |
download | tor-b3586629c9ce41393898b381159ba331906f8fc3.tar.gz tor-b3586629c9ce41393898b381159ba331906f8fc3.zip |
Wrap the function we use to run the event loop.
Doing this lets us remove the event2/event.h header from a few more
modules, particularly in the tests.
Part of work on 23750.
-rw-r--r-- | src/common/compat_libevent.h | 1 | ||||
-rw-r--r-- | src/or/main.c | 4 | ||||
-rw-r--r-- | src/test/test-timers.c | 4 | ||||
-rw-r--r-- | src/test/test_channelpadding.c | 4 | ||||
-rw-r--r-- | src/test/test_workqueue.c | 2 |
5 files changed, 7 insertions, 8 deletions
diff --git a/src/common/compat_libevent.h b/src/common/compat_libevent.h index 86bc77ba5f..c8b0371564 100644 --- a/src/common/compat_libevent.h +++ b/src/common/compat_libevent.h @@ -72,6 +72,7 @@ void tor_gettimeofday_cache_set(const struct timeval *tv); void tor_libevent_postfork(void); #endif +int tor_libevent_run_event_loop(struct event_base *base, int once); void tor_libevent_exit_loop_after_delay(struct event_base *base, const struct timeval *delay); void tor_libevent_exit_loop_after_callback(struct event_base *base); diff --git a/src/or/main.c b/src/or/main.c index 9a8ac30886..d1df11af50 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -2832,8 +2832,8 @@ run_main_loop_once(void) * an event, or the second ends, or until we have some active linked * connections to trigger events for. Libevent will wait till one * of these happens, then run all the appropriate callbacks. */ - loop_result = event_base_loop(tor_libevent_get_base(), - called_loop_once ? EVLOOP_ONCE : 0); + loop_result = tor_libevent_run_event_loop(tor_libevent_get_base(), + called_loop_once); if (get_options()->MainloopStats) { /* Update our main loop counters. */ diff --git a/src/test/test-timers.c b/src/test/test-timers.c index 1b4466ecc2..5efd99cacf 100644 --- a/src/test/test-timers.c +++ b/src/test/test-timers.c @@ -7,8 +7,6 @@ #include <stdio.h> #include <string.h> -#include <event2/event.h> - #include "compat.h" #include "compat_libevent.h" #include "crypto.h" @@ -90,7 +88,7 @@ main(int argc, char **argv) --n_active_timers; } - event_base_loop(tor_libevent_get_base(), 0); + tor_libevent_run_event_loop(tor_libevent_get_base(), 0); int64_t total_difference = 0; uint64_t total_square_difference = 0; diff --git a/src/test/test_channelpadding.c b/src/test/test_channelpadding.c index 072a347de7..2c803c3443 100644 --- a/src/test/test_channelpadding.c +++ b/src/test/test_channelpadding.c @@ -15,7 +15,6 @@ #include "channelpadding.h" #include "compat_libevent.h" #include "config.h" -#include <event2/event.h> #include "compat_time.h" #include "main.h" #include "networkstatus.h" @@ -264,7 +263,8 @@ dummy_nop_timer(void) timer_schedule(dummy_timer, &timeout); - event_base_loop(tor_libevent_get_base(), 0); + tor_libevent_run_event_loop(tor_libevent_get_base(), 0); + timer_free(dummy_timer); } diff --git a/src/test/test_workqueue.c b/src/test/test_workqueue.c index de7884ff99..2a02611479 100644 --- a/src/test/test_workqueue.c +++ b/src/test/test_workqueue.c @@ -436,7 +436,7 @@ main(int argc, char **argv) tor_libevent_exit_loop_after_delay(tor_libevent_get_base(), &limit); } - event_base_loop(tor_libevent_get_base(), 0); + tor_libevent_run_event_loop(tor_libevent_get_base(), 0); if (n_sent != opt_n_items || n_received+n_successful_cancel != n_sent) { printf("%d vs %d\n", n_sent, opt_n_items); |