From 55e991b27ca40f5e1cdf33a85a27db5eff5f19d5 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Mon, 26 Mar 2012 17:35:21 -0400 Subject: [PATCH] Make libevent_global_shutdown() idempotent Two calls to libevent_global_shutdown on your exit path shouldn't result in a crash. --- event.c | 1 + evutil_rand.c | 1 + signal.c | 1 + 3 files changed, 3 insertions(+) diff --git a/event.c b/event.c index bb4c4c88..0b78b743 100644 --- a/event.c +++ b/event.c @@ -3168,6 +3168,7 @@ event_free_debug_globals_locks(void) #ifndef EVENT__DISABLE_DEBUG_MODE if (event_debug_map_lock_ != NULL) { EVTHREAD_FREE_LOCK(event_debug_map_lock_, 0); + event_debug_map_lock_ = NULL; } #endif /* EVENT__DISABLE_DEBUG_MODE */ #endif /* EVENT__DISABLE_THREAD_SUPPORT */ diff --git a/evutil_rand.c b/evutil_rand.c index 9259335c..dd566bac 100644 --- a/evutil_rand.c +++ b/evutil_rand.c @@ -124,6 +124,7 @@ evutil_free_secure_rng_globals_locks(void) #ifndef EVENT__DISABLE_THREAD_SUPPORT if (arc4rand_lock != NULL) { EVTHREAD_FREE_LOCK(arc4rand_lock, 0); + arc4rand_lock = NULL; } #endif return; diff --git a/signal.c b/signal.c index c8ae5c22..e5dd555e 100644 --- a/signal.c +++ b/signal.c @@ -455,6 +455,7 @@ evsig_free_globals_locks(void) #ifndef EVENT__DISABLE_THREAD_SUPPORT if (evsig_base_lock != NULL) { EVTHREAD_FREE_LOCK(evsig_base_lock, 0); + evsig_base_lock = NULL; } #endif return;