summaryrefslogtreecommitdiff
path: root/src/or/main.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2017-10-03 10:44:45 -0400
committerNick Mathewson <nickm@torproject.org>2018-04-05 12:35:11 -0400
commit871ff0006d052967534fb6ce31465b55021888f0 (patch)
treef3a489068b883fd059dee3e86f20d2a3c45682e0 /src/or/main.c
parentf9e32a20843cca221f5d61688000a87fb2babaf8 (diff)
downloadtor-871ff0006d052967534fb6ce31465b55021888f0.tar.gz
tor-871ff0006d052967534fb6ce31465b55021888f0.zip
Add an API for a scheduled/manually activated event in the mainloop
Using this API lets us remove event2/event.h usage from half a dozen modules, to better isolate libevent. Implements part of ticket 23750.
Diffstat (limited to 'src/or/main.c')
-rw-r--r--src/or/main.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/or/main.c b/src/or/main.c
index a0d2ae0757..9f26732a29 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -1060,9 +1060,8 @@ conn_close_if_marked(int i)
* reason.
*/
static void
-directory_all_unreachable_cb(evutil_socket_t fd, short event, void *arg)
+directory_all_unreachable_cb(mainloop_event_t *event, void *arg)
{
- (void)fd;
(void)event;
(void)arg;
@@ -1082,7 +1081,7 @@ directory_all_unreachable_cb(evutil_socket_t fd, short event, void *arg)
control_event_general_error("DIR_ALL_UNREACHABLE");
}
-static struct event *directory_all_unreachable_cb_event = NULL;
+static mainloop_event_t *directory_all_unreachable_cb_event = NULL;
/** We've just tried every dirserver we know about, and none of
* them were reachable. Assume the network is down. Change state
@@ -1099,12 +1098,11 @@ directory_all_unreachable(time_t now)
if (!directory_all_unreachable_cb_event) {
directory_all_unreachable_cb_event =
- tor_event_new(tor_libevent_get_base(),
- -1, EV_READ, directory_all_unreachable_cb, NULL);
+ mainloop_event_new(directory_all_unreachable_cb, NULL);
tor_assert(directory_all_unreachable_cb_event);
}
- event_active(directory_all_unreachable_cb_event, EV_READ, 1);
+ mainloop_event_activate(directory_all_unreachable_cb_event);
}
/** This function is called whenever we successfully pull down some new
@@ -3525,6 +3523,7 @@ tor_free_all(int postfork)
periodic_timer_free(refill_timer);
tor_event_free(shutdown_did_not_work_event);
tor_event_free(initialize_periodic_events_event);
+ mainloop_event_free(directory_all_unreachable_cb_event);
#ifdef HAVE_SYSTEMD_209
periodic_timer_free(systemd_watchdog_timer);