From 469b432ebeb489ba13a1fa30ca713723800fa83f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Tue, 27 Jun 2017 00:29:12 +0300 Subject: [PATCH] Detect and handle OpenSSL 1.1 OpenSSL 1.1 supports most of the native threading libraries, including pthread. This means that only versions before 1.1 need the thread handling code. --- CMakeLists.txt | 4 +++- server/core/gateway.cc | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 96d02b648..c98aa7f62 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -84,8 +84,10 @@ if(NOT OPENSSL_FOUND) else() if(OPENSSL_VERSION VERSION_LESS 1 AND NOT FORCE_OPENSSL100) add_definitions("-DOPENSSL_0_9") - else() + elseif(OPENSSL_VERSION VERSION_LESS 1.1) add_definitions("-DOPENSSL_1_0") + else() + add_definitions("-DOPENSSL_1_1") endif() endif() diff --git a/server/core/gateway.cc b/server/core/gateway.cc index b34196590..7adf4a317 100644 --- a/server/core/gateway.cc +++ b/server/core/gateway.cc @@ -189,6 +189,7 @@ static void modules_process_finish(); static bool modules_thread_init(); static void modules_thread_finish(); +#ifndef OPENSSL_1_1 /** SSL multi-threading functions and structures */ static SPINLOCK* ssl_locks; @@ -270,6 +271,7 @@ static void maxscale_ssl_id(CRYPTO_THREADID* id) CRYPTO_THREADID_set_numeric(id, pthread_self()); } #endif +#endif /** * Handler for SIGHUP signal. Reload the configuration for the @@ -1741,6 +1743,7 @@ int main(int argc, char **argv) SSL_load_error_strings(); OPENSSL_add_all_algorithms_noconf(); +#ifndef OPENSSL_1_1 numlocks = CRYPTO_num_locks(); if ((ssl_locks = (SPINLOCK*)MXS_MALLOC(sizeof(SPINLOCK) * (numlocks + 1))) == NULL) { @@ -1760,6 +1763,7 @@ int main(int argc, char **argv) CRYPTO_THREADID_set_callback(maxscale_ssl_id); #else CRYPTO_set_id_callback(pthread_self); +#endif #endif /**