Skip to content

Commit

Permalink
[2] try to fix #1121
Browse files Browse the repository at this point in the history
  • Loading branch information
matyhtf committed Nov 22, 2017
1 parent 6914d71 commit 48a2e57
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions include/Connection.h
Expand Up @@ -110,6 +110,7 @@ typedef struct
} swSSL_config;

void swSSL_init(void);
void swSSL_init_thread_safety();
int swSSL_server_set_cipher(SSL_CTX* ssl_context, swSSL_config *cfg);
void swSSL_server_http_advise(SSL_CTX* ssl_context, swSSL_config *cfg);
SSL_CTX* swSSL_get_context(swSSL_option *option);
Expand Down
5 changes: 5 additions & 0 deletions src/network/Port.c
Expand Up @@ -69,6 +69,11 @@ int swPort_enable_ssl_encrypt(swListenPort *ls)
swWarn("swSSL_get_context() error.");
return SW_ERR;
}
/**
* OpenSSL thread-safe
*/
swSSL_init_thread_safety();

if (ls->ssl_option.client_cert_file
&& swSSL_set_client_certificate(ls->ssl_context, ls->ssl_option.client_cert_file,
ls->ssl_option.verify_depth) == SW_ERR)
Expand Down
4 changes: 1 addition & 3 deletions src/protocol/SSL.c
Expand Up @@ -43,7 +43,6 @@ static int swSSL_npn_advertised(SSL *ssl, const uchar **out, uint32_t *outlen, v
static int swSSL_alpn_advertised(SSL *ssl, const uchar **out, uchar *outlen, const uchar *in, uint32_t inlen, void *arg);
#endif

static void swSSL_init_locks();
static ulong_t swSSL_thread_id(void);
static void swSSL_lock_callback(int mode, int type, char *file, int line);

Expand Down Expand Up @@ -117,7 +116,6 @@ void swSSL_init(void)
SSL_load_error_strings();
OpenSSL_add_all_algorithms();
#endif
swSSL_init_locks();
openssl_init = 1;
}

Expand All @@ -138,7 +136,7 @@ static ulong_t swSSL_thread_id(void)
return (ulong_t) pthread_self();;
}

static void swSSL_init_locks()
void swSSL_init_thread_safety()
{
int i;
lock_array = (pthread_mutex_t *) OPENSSL_malloc(CRYPTO_num_locks() * sizeof(pthread_mutex_t));
Expand Down

0 comments on commit 48a2e57

Please sign in to comment.