Skip to content

Commit

Permalink
core/rthreads.h: add new option tls_threads_mode = 2
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
space88man committed Mar 4, 2024
1 parent 5b8b271 commit e7f040f
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/core/rthreads.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit e7f040f

Please sign in to comment.