From 13fb88ea076c80da79182ec2ee5d9123ae6cd075 Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Wed, 24 Jun 2015 11:29:43 +0300 Subject: [PATCH] Added optional code for older OpenSSL library versions. --- CMakeLists.txt | 14 +++++++++++++- server/core/gateway.c | 14 +++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3b040f0df..c28b2c657 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,19 +31,31 @@ include(cmake/CheckPlatform.cmake) check_deps() check_dirs() +find_package(OpenSSL) find_package(Valgrind) find_package(MySQLClient) find_package(MySQL) find_package(Pandoc) find_package(TCMalloc) find_package(Jemalloc) +find_package(CURL) # You can find the variables set by this in the FindCURL.cmake file # which is a default module in CMake. -find_package(CURL) + if(NOT CURL_FOUND) message(FATAL_ERROR "Failed to locate dependency: libcurl") endif() +if(NOT OPENSSL_FOUND) + message(FATAL_ERROR "Failed to locate dependency: OpenSSL") +else() + if(OPENSSL_VERSION VERSION_LESS 1 AND NOT FORCE_OPENSSL100) + add_definitions("-DOPENSSL_0_9") + else() + add_definitions("-DOPENSSL_1_0") + endif() +endif() + set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${CMAKE_INSTALL_PREFIX}/${MAXSCALE_LIBDIR}) # Make sure the release notes for this release are present if it is a stable one diff --git a/server/core/gateway.c b/server/core/gateway.c index f206ca30e..5997a9eeb 100644 --- a/server/core/gateway.c +++ b/server/core/gateway.c @@ -263,6 +263,15 @@ static void ssl_free_dynlock(struct CRYPTO_dynlock_value * n,const char* file, i free(n); } +/** + * The thread ID callback function for OpenSSL dynamic locks. + * @param id Id to modify + */ +static void maxscale_ssl_id(CRYPTO_THREADID* id) +{ + CRYPTO_THREADID_set_numeric(id,pthread_self()); +} + /** * Handler for SIGHUP signal. Reload the configuration for the * gateway. @@ -1459,8 +1468,11 @@ int main(int argc, char **argv) CRYPTO_set_dynlock_create_callback(ssl_create_dynlock); CRYPTO_set_dynlock_destroy_callback(ssl_free_dynlock); CRYPTO_set_dynlock_lock_callback(ssl_lock_dynlock); +#ifdef OPENSSL_1_0 + CRYPTO_THREADID_set_callback(maxscale_ssl_id); +#else CRYPTO_set_id_callback(pthread_self); - +#endif /* register exit function for embedded MySQL library */ l = atexit(libmysqld_done);