Ensure Async is deinited properly
authorMatt Caswell <matt@openssl.org>
Wed, 2 Mar 2016 16:52:43 +0000 (16:52 +0000)
committerMatt Caswell <matt@openssl.org>
Wed, 2 Mar 2016 17:23:42 +0000 (17:23 +0000)
The global thread local keys were not being deinited properly in async.

Reviewed-by: Rich Salz <rsalz@openssl.org>
crypto/async/async.c
crypto/include/internal/async.h
crypto/init.c

index 67e19c730f3bc7857fb8d3afe0ded962a4bc2a3e..b4ba5618881789869e30df438463d82256741550 100644 (file)
@@ -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);
index e5d426baf30e24d71cd5c408abbf5d57c326eb80..76fe4d1399a09e8b327ebf8f97275347ab137af7 100644 (file)
@@ -58,4 +58,5 @@
 #include <openssl/async.h>
 
 int async_init(void);
+void async_deinit(void);
 
index cbe07df2a29e1eca3c2ef7319c0d2375fd7564f8..613606ebdc8e52e4086fcfefd05999656ca0ab51 100644 (file)
@@ -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