Skip to content

Commit

Permalink
Fix possible race condition at exit with OpenSSL
Browse files Browse the repository at this point in the history
  • Loading branch information
paullouisageneau committed Dec 2, 2024
1 parent 0d131af commit 86bc1cd
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/impl/tls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,11 @@ void init() {

std::lock_guard lock(mutex);
if (!std::exchange(done, true)) {
OPENSSL_init_ssl(OPENSSL_INIT_LOAD_SSL_STRINGS | OPENSSL_INIT_LOAD_CRYPTO_STRINGS, nullptr);
uint64_t ssl_opts = OPENSSL_INIT_LOAD_SSL_STRINGS | OPENSSL_INIT_LOAD_CRYPTO_STRINGS;
#ifdef OPENSSL_INIT_NO_ATEXIT
ssl_opts |= OPENSSL_INIT_NO_ATEXIT;
#endif
OPENSSL_init_ssl(ssl_opts, nullptr);
OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS, nullptr);
}
}
Expand Down

0 comments on commit 86bc1cd

Please sign in to comment.