diff options
author | Mark Ellzey <mark.thomas@mandiant.com> | 2011-07-12 12:25:41 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2012-03-22 11:57:04 -0400 |
commit | 041ca00c754eed316b7e3066613abee620aae9b5 (patch) | |
tree | 7c49e7b12dff949d15784dc4cc5150727a820a20 /evutil_rand.c | |
parent | 24dab0b3597a4062d479ce8ee38dc6abf81b9e57 (diff) | |
download | libevent-041ca00c754eed316b7e3066613abee620aae9b5.tar.gz |
Add a new libevent_global_shutdown() to free all globals before exiting.
Mark Ellzey added a function libevent_shutdown() which calls a set of
private functions:
* event_free_globals()
* event_free_debug_globals()
* event_free_debug_globals_locks()
* event_free_evsig_globals()
* evsig_free_globals()
* evsig_free_globals_locks()
* evutil_free_globals()
* evutil_free_secure_rng_globals()
* evutil_free_secure_rng_globals_lock()
Nick tweaked this libevent global shutdown code:
- rename the function to emphasize that it's for global resources
- write more in the doxygen
- make function brace style consistent
- add a missing void in a function definition.
Diffstat (limited to 'evutil_rand.c')
-rw-r--r-- | evutil_rand.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/evutil_rand.c b/evutil_rand.c index 58d8bd9e..fbb0ed43 100644 --- a/evutil_rand.c +++ b/evutil_rand.c @@ -50,11 +50,13 @@ evutil_secure_rng_init(void) (void) arc4random(); return 0; } +#ifndef EVENT__DISABLE_THREAD_SUPPORT int evutil_secure_rng_global_setup_locks_(const int enable_locks) { return 0; } +#endif static void ev_arc4random_buf(void *buf, size_t n) @@ -112,6 +114,22 @@ evutil_secure_rng_global_setup_locks_(const int enable_locks) } #endif +static void +evutil_free_secure_rng_globals_locks(void) +{ +#ifndef EVENT__DISABLE_THREAD_SUPPORT + if (arc4rand_lock != NULL) { + EVTHREAD_FREE_LOCK(arc4rand_lock, 0); + } +#endif + return; +} +void +evutil_free_secure_rng_globals_(void) { +{ + evutil_free_secure_rng_globals_locks(); +} + int evutil_secure_rng_init(void) { |