You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
kamailio/debian/patches/upstream/tls-init-early-the-local-lo...

50 lines
1.6 KiB

From: Daniel-Constantin Mierla <miconda@gmail.com>
Date: Fri, 8 Dec 2023 12:34:56 +0100
Subject: tls: init early the local lock for memory
- needed to done before mod param init_mode is set
- runtime uses the modparam to do lock/unlock
- #3668
(cherry picked from commit 1a9b0b63617afebcee2aecb3b2240d7684ecabc2)
---
src/modules/tls/tls_init.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/src/modules/tls/tls_init.c b/src/modules/tls/tls_init.c
index 6106cc7..57be9ca 100644
--- a/src/modules/tls/tls_init.c
+++ b/src/modules/tls/tls_init.c
@@ -78,7 +78,7 @@ int ksr_tls_lock_init(void)
{
pthread_mutexattr_t attr;
- if(!(ksr_tls_init_mode & TLS_MODE_PTHREAD_LOCK_SHM)) {
+ if(ksr_tls_lock_shm != NULL) {
return 0;
}
ksr_tls_lock_shm = (pthread_mutex_t *)shm_mallocxz(sizeof(pthread_mutex_t));
@@ -723,6 +723,11 @@ int tls_pre_init(void)
LM_INFO("libssl linked mode: static\n");
#endif
+ if(ksr_tls_lock_init() < 0) {
+ LM_ERR("failed to init local lock\n");
+ return -1;
+ }
+
/*
* this has to be called before any function calling CRYPTO_malloc,
* CRYPTO_malloc will set allow_customize in openssl to 0
@@ -770,6 +775,10 @@ int tls_h_mod_pre_init_f(void)
LM_DBG("already mod pre-initialized\n");
return 0;
}
+ if(ksr_tls_lock_init() < 0) {
+ LM_ERR("failed to init local lock\n");
+ return -1;
+ }
LM_DBG("preparing tls env for modules initialization\n");
#if OPENSSL_VERSION_NUMBER >= 0x010100000L && !defined(LIBRESSL_VERSION_NUMBER)
LM_DBG("preparing tls env for modules initialization (libssl >=1.1)\n");