diff options
author | Nick Mathewson <nickm@torproject.org> | 2017-12-11 11:33:54 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2017-12-11 11:52:19 -0500 |
commit | 322abc030e53c7e84ca9f22a47b2965f262f5ffa (patch) | |
tree | 12d96003ef5fe66aeaa20654a4c5af79aca67c3b /src/common | |
parent | ea929e8456d065a25d7eb5e2e0e41e0f303ebe9d (diff) | |
download | tor-322abc030e53c7e84ca9f22a47b2965f262f5ffa.tar.gz tor-322abc030e53c7e84ca9f22a47b2965f262f5ffa.zip |
On exit, free the event_base and set its pointer to NULL.
When we didn't do this before, we'd have some still-reachable memory
warnings, and we'd find ourselves crashing when we tried to
reinitialize libevent.
Part of 24581 (don't crash when restarting Tor in-process)
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/compat_libevent.c | 10 | ||||
-rw-r--r-- | src/common/compat_libevent.h | 1 |
2 files changed, 11 insertions, 0 deletions
diff --git a/src/common/compat_libevent.c b/src/common/compat_libevent.c index 10489bf296..b5e9cc9332 100644 --- a/src/common/compat_libevent.c +++ b/src/common/compat_libevent.c @@ -237,6 +237,16 @@ tor_init_libevent_rng(void) return rv; } +/** + * Un-initialize libevent in preparation for an exit + */ +void +tor_libevent_free_all(void) +{ + event_base_free(the_event_base); + the_event_base = NULL; +} + #if defined(LIBEVENT_VERSION_NUMBER) && \ LIBEVENT_VERSION_NUMBER >= V(2,1,1) && \ !defined(TOR_UNIT_TESTS) diff --git a/src/common/compat_libevent.h b/src/common/compat_libevent.h index 0cdb73fbb9..1853e50917 100644 --- a/src/common/compat_libevent.h +++ b/src/common/compat_libevent.h @@ -52,6 +52,7 @@ const char *tor_libevent_get_method(void); void tor_check_libevent_header_compatibility(void); const char *tor_libevent_get_version_str(void); const char *tor_libevent_get_header_version_str(void); +void tor_libevent_free_all(void); int tor_init_libevent_rng(void); |