Module: kamailio
Branch: 5.7
Commit: d20df6fb372ab4da0dd5e6f277b08345059c2be5
URL:
https://github.com/kamailio/kamailio/commit/d20df6fb372ab4da0dd5e6f277b0834…
Author: S-P Chan <shihping.chan(a)gmail.com>
Committer: S-P Chan <shihping.chan(a)gmail.com>
Date: 2024-03-23T21:09:14+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
(cherry picked from commit e7f040f219b46592081a6053b4ed1ae0d0552b1a)
---
Modified: src/core/rthreads.h
---
Diff:
https://github.com/kamailio/kamailio/commit/d20df6fb372ab4da0dd5e6f277b0834…
Patch:
https://github.com/kamailio/kamailio/commit/d20df6fb372ab4da0dd5e6f277b0834…
---
diff --git a/src/core/rthreads.h b/src/core/rthreads.h
index 0f4f0cf8b8a..6fee4d0b407 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;
- 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;
- 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;
- 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;
- 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;
- 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);
}