mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice
synced 2026-08-12 19:05:07 +00:00
Initialise OpenSSL just once
Avoid multiple initializations of this library. Also initialize using thread safe code to avoid possible race conditions. Signed-off-by: Frediano Ziglio <fziglio@redhat.com> Acked-by: Pavel Grunt <pgrunt@redhat.com>
This commit is contained in:
parent
e0a0ede078
commit
356f819e50
@ -2801,8 +2801,19 @@ static void openssl_thread_setup(void)
|
||||
CRYPTO_set_locking_callback(pthreads_locking_callback);
|
||||
}
|
||||
|
||||
static gpointer openssl_global_init(gpointer arg)
|
||||
{
|
||||
SSL_library_init();
|
||||
SSL_load_error_strings();
|
||||
|
||||
openssl_thread_setup();
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int reds_init_ssl(RedsState *reds)
|
||||
{
|
||||
static GOnce openssl_once = G_ONCE_INIT;
|
||||
#if OPENSSL_VERSION_NUMBER >= 0x10000000L
|
||||
const SSL_METHOD *ssl_method;
|
||||
#else
|
||||
@ -2814,8 +2825,7 @@ static int reds_init_ssl(RedsState *reds)
|
||||
long ssl_options = SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3;
|
||||
|
||||
/* Global system initialization*/
|
||||
SSL_library_init();
|
||||
SSL_load_error_strings();
|
||||
g_once(&openssl_once, openssl_global_init, NULL);
|
||||
|
||||
/* Create our context*/
|
||||
/* SSLv23_method() handles TLSv1.x in addition to SSLv2/v3 */
|
||||
@ -2879,8 +2889,6 @@ static int reds_init_ssl(RedsState *reds)
|
||||
}
|
||||
}
|
||||
|
||||
openssl_thread_setup();
|
||||
|
||||
#ifndef SSL_OP_NO_COMPRESSION
|
||||
STACK *cmp_stack = SSL_COMP_get_compression_methods();
|
||||
sk_zero(cmp_stack);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user