summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2017-05-10 11:00:07 -0400
committerNick Mathewson <nickm@torproject.org>2017-05-10 11:01:13 -0400
commit95fa7d1cf82c68d7d39f423cf71fa8e097662de3 (patch)
tree5dd9be715a3d977ec865fed0bcf24d806548b2f2 /src/common
parent0266c4ac819d9c835a77a0c1e0334f26f60f6f77 (diff)
downloadtor-95fa7d1cf82c68d7d39f423cf71fa8e097662de3.tar.gz
tor-95fa7d1cf82c68d7d39f423cf71fa8e097662de3.zip
In channelpadding tests that touch libevent, call event_reinit().
This is necessary to avoid crashes and test failures on kevent-based systems. Fixes bug 22209; bug not in any released Tor.
Diffstat (limited to 'src/common')
-rw-r--r--src/common/compat_libevent.c9
-rw-r--r--src/common/compat_libevent.h1
2 files changed, 10 insertions, 0 deletions
diff --git a/src/common/compat_libevent.c b/src/common/compat_libevent.c
index 1146d02168..31eb4ac496 100644
--- a/src/common/compat_libevent.c
+++ b/src/common/compat_libevent.c
@@ -280,6 +280,15 @@ tor_gettimeofday_cache_set(const struct timeval *tv)
tor_assert(tv);
memcpy(&cached_time_hires, tv, sizeof(*tv));
}
+
+/** For testing: called post-fork to make libevent reinitialize
+ * kernel structures. */
+void
+tor_libevent_postfork(void)
+{
+ int r = event_reinit(tor_libevent_get_base());
+ tor_assert(r == 0);
+}
#endif
#endif
diff --git a/src/common/compat_libevent.h b/src/common/compat_libevent.h
index 96c48d53a1..904938415c 100644
--- a/src/common/compat_libevent.h
+++ b/src/common/compat_libevent.h
@@ -54,6 +54,7 @@ void tor_gettimeofday_cached(struct timeval *tv);
void tor_gettimeofday_cache_clear(void);
#ifdef TOR_UNIT_TESTS
void tor_gettimeofday_cache_set(const struct timeval *tv);
+void tor_libevent_postfork(void);
#endif
#ifdef COMPAT_LIBEVENT_PRIVATE