From: David Goulet Date: Fri, 27 Apr 2018 15:14:33 +0000 (-0400) Subject: main: Don't rescan main loop events if not initialized X-Git-Tag: tor-0.3.4.1-alpha~111 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3ab017b10c64e090a5a3f197315ddcdbc6de698c;p=thirdparty%2Ftor.git main: Don't rescan main loop events if not initialized This is done because it makes our life easier with unit tests. Also, a rescan on an uninitialized event list will result in a stacktrace. Signed-off-by: David Goulet --- diff --git a/src/or/main.c b/src/or/main.c index c1103edb3a..10f26c954e 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -1553,6 +1553,13 @@ rescan_periodic_events(const or_options_t *options) { tor_assert(options); + /* Avoid scanning the event list if we haven't initialized it yet. This is + * particularly useful for unit tests in order to avoid initializing main + * loop events everytime. */ + if (!periodic_events_initialized) { + return; + } + int roles = get_my_roles(options); for (int i = 0; periodic_events[i].name; ++i) {