From 047985fb91a21c94fc6446ba1e26de33ae8aa74c Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Wed, 24 Jun 2015 15:26:35 +0300 Subject: [PATCH] Fixed SSL thread locking functions not being used. --- server/core/gateway.c | 40 ++++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/server/core/gateway.c b/server/core/gateway.c index 5997a9eeb..1b653d2f7 100644 --- a/server/core/gateway.c +++ b/server/core/gateway.c @@ -208,6 +208,15 @@ static int set_user(); /** SSL multi-threading functions and structures */ +static SPINLOCK* ssl_locks; + +static void ssl_locking_function(int mode,int n,const char* file, int line) +{ + if(mode & CRYPTO_LOCK) + spinlock_acquire(&ssl_locks[n]); + else + spinlock_release(&ssl_locks[n]); +} /** * OpenSSL requires this struct to be defined in order to use dynamic locks */ @@ -1465,14 +1474,19 @@ int main(int argc, char **argv) SSL_library_init(); SSL_load_error_strings(); OPENSSL_add_all_algorithms_noconf(); - 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 + + int numlocks = CRYPTO_num_locks(); + if((ssl_locks = malloc(sizeof(SPINLOCK)*(numlocks + 1))) == NULL) + { + char* logerr = "Memory allocation failed"; + print_log_n_stderr(true, true, logerr, logerr, eno); + rc = MAXSCALE_INTERNALERROR; + goto return_main; + } + + for(i = 0;i