]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-ssl-iostream: Detect whether to call ERR_remove_[thread_]state() via configure
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Sun, 5 Feb 2017 19:38:33 +0000 (21:38 +0200)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 6 Feb 2017 14:36:37 +0000 (16:36 +0200)
configure.ac
src/lib-ssl-iostream/dovecot-openssl-common.c

index 956e25977d018dfa22ce41728b6cef8f7533d8dc..9f2bbdb9b81140f5fe91d199cacd6a7b34026c73 100644 (file)
@@ -1769,6 +1769,12 @@ if test $want_openssl != no && test $have_ssl = no; then
       AC_DEFINE(HAVE_SSL_NEW_MEM_FUNCS,, [Define if CRYPTO_set_mem_functions has new style parameters])
     fi
 
+    AC_CHECK_LIB(ssl, ERR_remove_thread_state, [
+      AC_DEFINE(HAVE_OPENSSL_ERR_REMOVE_THREAD_STATE,, [Define if you have ERR_remove_thread_state])
+    ],, $SSL_LIBS)
+    AC_CHECK_LIB(ssl, OPENSSL_thread_stop, [
+      AC_DEFINE(HAVE_OPENSSL_AUTO_THREAD_DEINIT,, [Define if OpenSSL performs thread cleanup automatically])
+    ],, $SSL_LIBS)
     AC_CHECK_LIB(ssl, OPENSSL_cleanup, [
       AC_DEFINE(HAVE_OPENSSL_CLEANUP,, [OpenSSL supports OPENSSL_cleanup()])
     ],, $SSL_LIBS)
index dbe63860c6872b76076a2a0a206db0e31f52e34c..e53a2d77b86cd6eed56d463226b3453bf5eeec7f 100644 (file)
@@ -95,10 +95,14 @@ bool dovecot_openssl_common_global_unref(void)
        ENGINE_cleanup();
        EVP_cleanup();
        CRYPTO_cleanup_all_ex_data();
-#if OPENSSL_VERSION_NUMBER < 0x10000000L
-       ERR_remove_state(0);
-#elif OPENSSL_VERSION_NUMBER < 0x10100000L
+#ifdef HAVE_OPENSSL_AUTO_THREAD_DEINIT
+       /* no cleanup needed */
+#elif defined(HAVE_OPENSSL_ERR_REMOVE_THREAD_STATE)
+       /* This was marked as deprecated in v1.1. */
        ERR_remove_thread_state(NULL);
+#else
+       /* This was deprecated by ERR_remove_thread_state(NULL) in v1.0.0. */
+       ERR_remove_state(0);
 #endif
        ERR_free_strings();
 #ifdef HAVE_OPENSSL_CLEANUP