mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2025-07-25 12:15:32 +03:00
34 lines
1.3 KiB
Diff
34 lines
1.3 KiB
Diff
diff --git a/src/hermes.cpp b/src/hermes.cpp
|
|
index edfe833..35b4062 100644
|
|
--- a/src/hermes.cpp
|
|
+++ b/src/hermes.cpp
|
|
@@ -63,12 +63,14 @@ __thread unsigned long connection_id;
|
|
list<unsigned long> children;
|
|
|
|
#ifdef HAVE_SSL
|
|
-pthread_mutex_t ssl_locks[CRYPTO_NUM_LOCKS]={PTHREAD_MUTEX_INITIALIZER};
|
|
+#define CRYPTO_NUM_LOCKS 100
|
|
+pthread_mutex_t *ssl_locks;
|
|
|
|
void ssl_locking_function(int mode,int n,const char *file,int line)
|
|
{
|
|
- if(n>CRYPTO_NUM_LOCKS)
|
|
- throw Exception(_("Error, "+Utils::inttostr(n)+" is bigger than CRYPTO_NUM_LOCKS("+Utils::inttostr(CRYPTO_NUM_LOCKS)+")"),__FILE__,__LINE__);
|
|
+ int num_locks = CRYPTO_num_locks();
|
|
+ if(n>num_locks)
|
|
+ throw Exception(_("Error, "+Utils::inttostr(n)+" is bigger than CRYPTO_NUM_LOCKS("+Utils::inttostr(num_locks)+")"),__FILE__,__LINE__);
|
|
if(mode&CRYPTO_LOCK)
|
|
pthread_mutex_lock(&ssl_locks[n]);
|
|
else
|
|
@@ -94,6 +96,11 @@ main
|
|
*/
|
|
|
|
#ifdef HAVE_SSL
|
|
+ int num_locks=CRYPTO_num_locks();
|
|
+ ssl_locks = (pthread_mutex_t *)calloc(num_locks, sizeof (*ssl_locks));
|
|
+ for (int i=0; i< num_locks; i++)
|
|
+ pthread_mutex_init(&ssl_locks[i], NULL);
|
|
+
|
|
CRYPTO_set_locking_callback(ssl_locking_function);
|
|
#ifndef WIN32 //getpid() returns different values for threads on windows, therefor this is not needed
|
|
CRYPTO_set_id_callback(pthread_self);
|