mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-30 18:57:27 +02:00
Register cleanup with atexit for OpenSSL compat layer
This commit is contained in:
@ -115,7 +115,7 @@ AC_C_BIGENDIAN
|
|||||||
# check if functions of interest are linkable, but also check if
|
# check if functions of interest are linkable, but also check if
|
||||||
# they're declared by the expected headers, and if not, supersede the
|
# they're declared by the expected headers, and if not, supersede the
|
||||||
# unusable positive from AC_CHECK_FUNCS().
|
# unusable positive from AC_CHECK_FUNCS().
|
||||||
AC_CHECK_FUNCS([gethostbyname getaddrinfo gettimeofday gmtime_r inet_ntoa memset socket strftime])
|
AC_CHECK_FUNCS([gethostbyname getaddrinfo gettimeofday gmtime_r inet_ntoa memset socket strftime atexit])
|
||||||
AC_CHECK_DECLS([gethostbyname, getaddrinfo, gettimeofday, gmtime_r, inet_ntoa, memset, socket, strftime], [], [
|
AC_CHECK_DECLS([gethostbyname, getaddrinfo, gettimeofday, gmtime_r, inet_ntoa, memset, socket, strftime], [], [
|
||||||
if test "$(eval echo \$"$(eval 'echo ac_cv_func_${as_decl_name}')")" = "yes"
|
if test "$(eval echo \$"$(eval 'echo ac_cv_func_${as_decl_name}')")" = "yes"
|
||||||
then
|
then
|
||||||
|
18
src/ssl.c
18
src/ssl.c
@ -5004,6 +5004,16 @@ int AddCA(WOLFSSL_CERT_MANAGER* cm, DerBuffer** pDer, int type, int verify)
|
|||||||
static int wolfSSL_RAND_InitMutex(void);
|
static int wolfSSL_RAND_InitMutex(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(OPENSSL_EXTRA) && defined(HAVE_ATEXIT)
|
||||||
|
static void AtExitCleanup(void)
|
||||||
|
{
|
||||||
|
if (initRefCount > 0) {
|
||||||
|
initRefCount = 1;
|
||||||
|
(void)wolfSSL_Cleanup();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
WOLFSSL_ABI
|
WOLFSSL_ABI
|
||||||
int wolfSSL_Init(void)
|
int wolfSSL_Init(void)
|
||||||
{
|
{
|
||||||
@ -5024,6 +5034,14 @@ int wolfSSL_Init(void)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef OPENSSL_EXTRA
|
#ifdef OPENSSL_EXTRA
|
||||||
|
#ifdef HAVE_ATEXIT
|
||||||
|
/* OpenSSL registers cleanup using atexit */
|
||||||
|
if (atexit(AtExitCleanup) != 0) {
|
||||||
|
WOLFSSL_MSG("Bad atexit registration");
|
||||||
|
return WC_INIT_E;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef WOLFSSL_NO_OPENSSL_RAND_CB
|
#ifndef WOLFSSL_NO_OPENSSL_RAND_CB
|
||||||
if (wolfSSL_RAND_InitMutex() != 0) {
|
if (wolfSSL_RAND_InitMutex() != 0) {
|
||||||
return BAD_MUTEX_E;
|
return BAD_MUTEX_E;
|
||||||
|
Reference in New Issue
Block a user