diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2022-04-10 13:26:34 +0300 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2022-04-11 20:59:49 +0300 |
commit | a646d031e70e5f30cf15153299914afb03992159 (patch) | |
tree | 4ae9be99e7728e2bee68316e94556e5eee7928af /pthread_stop_world.c | |
parent | 34d820059a47e62e728506125fb93fd037712b45 (diff) | |
download | bdwgc-a646d031e70e5f30cf15153299914afb03992159.tar.gz |
Do not send signal to thread which is suspended manually
If thread is in do-blocking state (i.e. thread_blocked is set), then
suspend it only when it exits from the state.
* pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL
&& GC_ENABLE_SUSPEND_THREAD] (GC_suspend_thread): If thread_blocked
then set thread_blocked, then UNLOCK and return; update comment;
check FINISHED flag before checking t is self thread.
* pthread_support.c [GC_ENABLE_SUSPEND_THREAD
&& SIGNAL_BASED_STOP_WORLD] (GC_do_blocking_inner,
GC_call_with_gc_active): Call GC_suspend_self_inner() not holding GC
lock while suspended_ext (before setting thread_blocked to false).
Diffstat (limited to 'pthread_stop_world.c')
-rw-r--r-- | pthread_stop_world.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/pthread_stop_world.c b/pthread_stop_world.c index 7713da9d..65dd2319 100644 --- a/pthread_stop_world.c +++ b/pthread_stop_world.c @@ -647,6 +647,12 @@ STATIC void GC_restart_handler(int sig) UNLOCK(); return; } + if ((t -> flags & FINISHED) != 0 || t -> thread_blocked) { + t -> suspended_ext = TRUE; + /* Terminated but not joined yet, or in do-blocking state. */ + UNLOCK(); + return; + } if (THREAD_EQUAL((pthread_t)thread, pthread_self())) { t -> suspended_ext = TRUE; @@ -656,12 +662,6 @@ STATIC void GC_restart_handler(int sig) (void)GC_do_blocking(GC_suspend_self_inner, t); return; } - if ((t -> flags & FINISHED) != 0) { - t -> suspended_ext = TRUE; - /* Terminated but not joined yet. */ - UNLOCK(); - return; - } DISABLE_CANCEL(cancel_state); /* GC_suspend_thread is not a cancellation point. */ |