Skip to content

Commit 86bc1cd

Browse files
Fix possible race condition at exit with OpenSSL
1 parent 0d131af commit 86bc1cd

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/impl/tls.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,11 @@ void init() {
158158

159159
std::lock_guard lock(mutex);
160160
if (!std::exchange(done, true)) {
161-
OPENSSL_init_ssl(OPENSSL_INIT_LOAD_SSL_STRINGS | OPENSSL_INIT_LOAD_CRYPTO_STRINGS, nullptr);
161+
uint64_t ssl_opts = OPENSSL_INIT_LOAD_SSL_STRINGS | OPENSSL_INIT_LOAD_CRYPTO_STRINGS;
162+
#ifdef OPENSSL_INIT_NO_ATEXIT
163+
ssl_opts |= OPENSSL_INIT_NO_ATEXIT;
164+
#endif
165+
OPENSSL_init_ssl(ssl_opts, nullptr);
162166
OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS, nullptr);
163167
}
164168
}

0 commit comments

Comments
 (0)