]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
main: Don't rescan main loop events if not initialized
authorDavid Goulet <dgoulet@torproject.org>
Fri, 27 Apr 2018 15:14:33 +0000 (11:14 -0400)
committerDavid Goulet <dgoulet@torproject.org>
Fri, 27 Apr 2018 15:16:57 +0000 (11:16 -0400)
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 <dgoulet@torproject.org>
src/or/main.c

index c1103edb3ac6762c77aa0d6ae2cacd79f2978b83..10f26c954e858a5022d04c37f220f43039b0fe5c 100644 (file)
@@ -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) {