From ed49f43a0390217e1c2df0054fb7352523be9a58 Mon Sep 17 00:00:00 2001 From: Matt Caswell Date: Wed, 2 Mar 2016 16:52:43 +0000 Subject: [PATCH] Ensure Async is deinited properly The global thread local keys were not being deinited properly in async. Reviewed-by: Rich Salz --- crypto/async/async.c | 2 -- crypto/include/internal/async.h | 1 + crypto/init.c | 10 ++++++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/crypto/async/async.c b/crypto/async/async.c index 67e19c730f..b4ba561888 100644 --- a/crypto/async/async.c +++ b/crypto/async/async.c @@ -351,8 +351,6 @@ int async_init(void) return 1; } -/* TODO: FIXME: This needs to be called by something!!! */ -void async_deinit(void); void async_deinit(void) { CRYPTO_THREAD_cleanup_local(&ctxkey); diff --git a/crypto/include/internal/async.h b/crypto/include/internal/async.h index e5d426baf3..76fe4d1399 100644 --- a/crypto/include/internal/async.h +++ b/crypto/include/internal/async.h @@ -58,4 +58,5 @@ #include int async_init(void); +void async_deinit(void); diff --git a/crypto/init.c b/crypto/init.c index cbe07df2a2..613606ebdc 100644 --- a/crypto/init.c +++ b/crypto/init.c @@ -580,6 +580,16 @@ void OPENSSL_cleanup(void) COMP_zlib_cleanup(); } +#ifndef OPENSSL_NO_ASYNC + if (async_inited) { +# ifdef OPENSSL_INIT_DEBUG + fprintf(stderr, "OPENSSL_INIT: OPENSSL_cleanup: " + "async_deinit()\n"); +# endif + async_deinit(); + } +#endif + #ifndef OPENSSL_NO_ENGINE if (engine_inited) { # ifdef OPENSSL_INIT_DEBUG -- 2.34.1