[tor-commits] [tor/master] main: Don't rescan main loop events if not initialized

nickm at torproject.org nickm at torproject.org
Fri Apr 27 16:33:15 UTC 2018


commit 3ab017b10c64e090a5a3f197315ddcdbc6de698c
Author: David Goulet <dgoulet at torproject.org>
Date:   Fri Apr 27 11:14:33 2018 -0400

    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 <dgoulet at torproject.org>
---
 src/or/main.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/or/main.c b/src/or/main.c
index c1103edb3..10f26c954 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) {





More information about the tor-commits mailing list