AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
OpenSSLCrypto Namespace Reference

Functions

AC_COMMON_API void threadsSetup ()
 Needs to be called before threads using openssl are spawned.
 
AC_COMMON_API void threadsCleanup ()
 Needs to be called after threads using openssl are despawned.
 

Detailed Description

A group of functions which setup openssl crypto module to work properly in multithreaded enviroment If not setup properly - it will crash

Function Documentation

◆ threadsCleanup()

void OpenSSLCrypto::threadsCleanup ( )

Needs to be called after threads using openssl are despawned.

88{
89#if defined(OPENSSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER < 0x1010000fL
90 CRYPTO_set_locking_callback(nullptr);
91 CRYPTO_THREADID_set_callback(nullptr);
92
93 for (int i = 0 ; i < CRYPTO_num_locks(); ++i)
94 {
95 delete cryptoLocks[i];
96 }
97
98 cryptoLocks.resize(0);
99#elif OPENSSL_VERSION_NUMBER >= 0x30000000L
100 OSSL_PROVIDER_unload(LegacyProvider);
101 OSSL_PROVIDER_unload(DefaultProvider);
102 OSSL_PROVIDER_set_default_search_path(nullptr, nullptr);
103#endif
104}

Referenced by main().

◆ threadsSetup()

void OpenSSLCrypto::threadsSetup ( )

Needs to be called before threads using openssl are spawned.

64{
65#if defined(OPENSSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER < 0x1010000fL
66 cryptoLocks.resize(CRYPTO_num_locks());
67
68 for (int i = 0 ; i < CRYPTO_num_locks(); ++i)
69 {
70 cryptoLocks[i] = new std::mutex();
71 }
72
73 (void)&threadIdCallback;
74 CRYPTO_THREADID_set_callback(threadIdCallback);
75
76 (void)&lockingCallback;
77 CRYPTO_set_locking_callback(lockingCallback);
78#elif OPENSSL_VERSION_NUMBER >= 0x30000000L
79#if AC_PLATFORM == AC_PLATFORM_WINDOWS
80 SetupLibrariesForWindows();
81#endif
82 LegacyProvider = OSSL_PROVIDER_load(nullptr, "legacy");
83 DefaultProvider = OSSL_PROVIDER_load(nullptr, "default");
84#endif
85}

Referenced by main().