mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-10 21:23:58 +01:00
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)
This commit is contained in:
parent
ea929e8456
commit
322abc030e
@ -237,6 +237,16 @@ tor_init_libevent_rng(void)
|
|||||||
return rv;
|
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) && \
|
#if defined(LIBEVENT_VERSION_NUMBER) && \
|
||||||
LIBEVENT_VERSION_NUMBER >= V(2,1,1) && \
|
LIBEVENT_VERSION_NUMBER >= V(2,1,1) && \
|
||||||
!defined(TOR_UNIT_TESTS)
|
!defined(TOR_UNIT_TESTS)
|
||||||
|
@ -52,6 +52,7 @@ const char *tor_libevent_get_method(void);
|
|||||||
void tor_check_libevent_header_compatibility(void);
|
void tor_check_libevent_header_compatibility(void);
|
||||||
const char *tor_libevent_get_version_str(void);
|
const char *tor_libevent_get_version_str(void);
|
||||||
const char *tor_libevent_get_header_version_str(void);
|
const char *tor_libevent_get_header_version_str(void);
|
||||||
|
void tor_libevent_free_all(void);
|
||||||
|
|
||||||
int tor_init_libevent_rng(void);
|
int tor_init_libevent_rng(void);
|
||||||
|
|
||||||
|
@ -3388,6 +3388,7 @@ tor_free_all(int postfork)
|
|||||||
if (!postfork) {
|
if (!postfork) {
|
||||||
release_lockfile();
|
release_lockfile();
|
||||||
}
|
}
|
||||||
|
tor_libevent_free_all();
|
||||||
/* Stuff in util.c and address.c*/
|
/* Stuff in util.c and address.c*/
|
||||||
if (!postfork) {
|
if (!postfork) {
|
||||||
escaped(NULL);
|
escaped(NULL);
|
||||||
|
Loading…
Reference in New Issue
Block a user