Fixed SSL thread locking functions not being used.
This commit is contained in:
parent
80d130ef0c
commit
047985fb91
@ -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<numlocks + 1;i++)
|
||||
spinlock_init(&ssl_locks[i]);
|
||||
|
||||
/* register exit function for embedded MySQL library */
|
||||
l = atexit(libmysqld_done);
|
||||
|
||||
@ -1806,6 +1820,16 @@ int main(int argc, char **argv)
|
||||
"MaxScale started with %d server threads.",
|
||||
config_threadcount())));
|
||||
|
||||
CRYPTO_set_locking_callback(ssl_locking_function);
|
||||
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
|
||||
|
||||
MaxScaleStarted = time(0);
|
||||
/*<
|
||||
* Serve clients.
|
||||
|
Loading…
x
Reference in New Issue
Block a user