mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-09-05 17:44:55 -06:00
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
This commit is contained in:
parent
01729c30ef
commit
d2ea86c98b
1 changed files with 11 additions and 8 deletions
|
|
@ -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
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue