Module: kamailio
Branch: master
Commit: 1a9b0b63617afebcee2aecb3b2240d7684ecabc2
URL:
https://github.com/kamailio/kamailio/commit/1a9b0b63617afebcee2aecb3b2240d7…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2023-12-08T12:34:56+01:00
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
---
Modified: src/modules/tls/tls_init.c
---
Diff:
https://github.com/kamailio/kamailio/commit/1a9b0b63617afebcee2aecb3b2240d7…
Patch:
https://github.com/kamailio/kamailio/commit/1a9b0b63617afebcee2aecb3b2240d7…
---
diff --git a/src/modules/tls/tls_init.c b/src/modules/tls/tls_init.c
index 7824245813b..9be5e1d4fab 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));
@@ -721,6 +721,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
@@ -772,6 +777,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");