From d2ea86c98bb40f4ec3e0b735f2422e08a04b8b60 Mon Sep 17 00:00:00 2001 From: cxl Date: Mon, 25 May 2020 16:12:27 +0000 Subject: [PATCH] Core/SSL: Added OPENSSL_thread_stop to cleanup after thread exit git-svn-id: svn://ultimatepp.org/upp/trunk@14500 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/Core/SSL/InitExit.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/uppsrc/Core/SSL/InitExit.cpp b/uppsrc/Core/SSL/InitExit.cpp index d4788939b..2a0356e86 100644 --- a/uppsrc/Core/SSL/InitExit.cpp +++ b/uppsrc/Core/SSL/InitExit.cpp @@ -73,9 +73,9 @@ void TcpSocketInit(); INITIALIZER(SSL) { + MemoryIgnoreLeaksBlock __; LLOG("SSL init"); TcpSocketInit(); - MemoryIgnoreLeaksBlock __; CRYPTO_set_mem_functions(SslAlloc, SslRealloc, SslFree); SSL_library_init(); SSL_load_error_strings(); @@ -83,6 +83,7 @@ INITIALIZER(SSL) EXITBLOCK { + MemoryIgnoreLeaksBlock __; CONF_modules_unload(1); EVP_cleanup(); ENGINE_cleanup(); @@ -92,34 +93,36 @@ EXITBLOCK if(pCOMP) sk_SSL_COMP_free( pCOMP ); ERR_remove_state(0); +#else + ERR_remove_thread_state(NULL); + OPENSSL_thread_stop(); #endif ERR_free_strings(); } -#if OPENSSL_VERSION_NUMBER < 0x10100000L static thread_local bool sThreadInit; static thread_local void (*sPrevExit)(); static void sslExitThread() { +#if OPENSSL_VERSION_NUMBER < 0x10100000L ERR_remove_state(0); +#else + ERR_remove_thread_state(NULL); + OPENSSL_thread_stop(); +#endif if(sPrevExit) (*sPrevExit)(); } void SslInitThread() { + MemoryIgnoreLeaksBlock __; if(sThreadInit || Thread::IsMain()) return; sThreadInit = true; sPrevExit = Thread::AtExit(sslExitThread); } -#else - -void SslInitThread() {} - -#endif - }