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.
This commit is contained in:
Nick Mathewson 2017-10-03 11:20:59 -04:00
parent 39cb04335f
commit b3586629c9
5 changed files with 7 additions and 8 deletions

View File

@ -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);

View File

@ -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. */

View File

@ -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;

View File

@ -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);
}

View File

@ -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);