Skip to content

Commit

Permalink
fixup OpenSSL cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaozg committed Sep 2, 2023
1 parent d089dbc commit 5d78643
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/openssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -420,8 +420,10 @@ static void openssl_finalize(void)
#if (OPENSSL_VERSION_NUMBER > 0x10100000L && !IS_LIBRESSL()) || \
LIBRESSL_VERSION_NUMBER > 0x30600000L
#if !IS_LIBRESSL()
/* This will be called automatically by the library when the thread exits. */
OPENSSL_thread_stop();
#endif
/* This is initiated automatically on application exit */
OPENSSL_cleanup();
#else

Expand Down Expand Up @@ -476,7 +478,11 @@ static void openssl_initialize() {
if (_guard) return;
_guard = 1;

#if (OPENSSL_VERSION_NUMBER < 0x10100000L || \
(IS_LIBRESSL() && LIBRESSL_VERSION_NUMBER < 0x30600000L))
/* Automatically do thread and resources cleanup above OpenSSL v1.1.1 */
atexit(openssl_finalize);
#endif

#if defined(OPENSSL_THREADS) && \
(OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER))
Expand Down

0 comments on commit 5d78643

Please sign in to comment.