Module: kamailio
Branch: master
Commit: e7f040f219b46592081a6053b4ed1ae0d0552b1a
URL:
https://github.com/kamailio/kamailio/commit/e7f040f219b46592081a6053b4ed1ae…
Author: S-P Chan <shihping.chan(a)gmail.com>
Committer: S-P Chan <shihping.chan(a)gmail.com>
Date: 2024-03-04T22:00:38+08:00
core/rthreads.h: add new option tls_threads_mode = 2
- add global handling of thread-locals with
tls_threads_mode = 2
- this will run a pthread_atfork handler to reset
all thread-locals to 0x0
- alternative solution to running functions
in thread executors
- requires tls.so to be loaded to be effective
---
Modified: src/core/rthreads.h
---
Diff:
https://github.com/kamailio/kamailio/commit/e7f040f219b46592081a6053b4ed1ae…
Patch:
https://github.com/kamailio/kamailio/commit/e7f040f219b46592081a6053b4ed1ae…
---
diff --git a/src/core/rthreads.h b/src/core/rthreads.h
index 1a04f9982c7..56d68cef276 100644
--- a/src/core/rthreads.h
+++ b/src/core/rthreads.h
@@ -40,7 +40,7 @@ static void *run_threadP(_thread_proto fn, void *arg)
pthread_t tid;
void *ret = NULL;
- if(likely(ksr_tls_threads_mode == 0
+ if(likely(ksr_tls_threads_mode == 0 || ksr_tls_threads_mode == 2
|| (ksr_tls_threads_mode == 1 && process_no > 0))) {
return fn(arg);
}
@@ -77,7 +77,7 @@ static void *run_threadPI(_thread_protoPI fn, void *arg1, int arg2)
pthread_t tid;
void *ret = NULL;
- if(likely(ksr_tls_threads_mode == 0
+ if(likely(ksr_tls_threads_mode == 0 || ksr_tls_threads_mode == 2
|| (ksr_tls_threads_mode == 1 && process_no > 0))) {
return fn(arg1, arg2);
}
@@ -113,7 +113,7 @@ static void run_threadV(_thread_protoV fn)
#ifdef USE_TLS
pthread_t tid;
- if(likely(ksr_tls_threads_mode == 0
+ if(likely(ksr_tls_threads_mode == 0 || ksr_tls_threads_mode == 2
|| (ksr_tls_threads_mode == 1 && process_no > 0))) {
fn();
return;
@@ -152,7 +152,7 @@ static int run_thread4PP(_thread_proto4PP fn, void *arg1, void *arg2)
pthread_t tid;
int ret = 0;
- if(likely(ksr_tls_threads_mode == 0
+ if(likely(ksr_tls_threads_mode == 0 || ksr_tls_threads_mode == 2
|| (ksr_tls_threads_mode == 1 && process_no > 0))) {
return fn(arg1, arg2);
}
@@ -188,7 +188,7 @@ static void run_thread0P(_thread_proto0P fn, void *arg1)
#ifdef USE_TLS
pthread_t tid;
- if(likely(ksr_tls_threads_mode == 0
+ if(likely(ksr_tls_threads_mode == 0 || ksr_tls_threads_mode == 2
|| (ksr_tls_threads_mode == 1 && process_no > 0))) {
fn(arg1);
return;
@@ -240,7 +240,7 @@ static int run_thread4P5I2P2(_thread_proto4P5I2P2 fn, void *arg1, void
*arg2,
pthread_t tid;
int ret = 0;
- if(likely(ksr_tls_threads_mode == 0
+ if(likely(ksr_tls_threads_mode == 0 || ksr_tls_threads_mode == 2
|| (ksr_tls_threads_mode == 1 && process_no > 0))) {
return fn(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);
}
@@ -278,7 +278,7 @@ static int run_thread4L(_thread_proto4L fn, long arg1)
pthread_t tid;
int ret = 0;
- if(likely(ksr_tls_threads_mode == 0
+ if(likely(ksr_tls_threads_mode == 0 || ksr_tls_threads_mode == 2
|| (ksr_tls_threads_mode == 1 && process_no > 0))) {
return fn(arg1);
}