Mark thread as dead in case of ESRCH 87/317387/1
authorKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Tue, 31 Dec 2024 12:33:27 +0000 (13:33 +0100)
committerKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Tue, 31 Dec 2024 12:35:58 +0000 (13:35 +0100)
This may speed up the thread sync a bit

Change-Id: Ib6a9c8f11a719615227efd24da18c65b91d69bf0

src/client/client-security-manager.cpp

index bba070499994e4555785778cd0b2174719e404af..4ad41eef49f19afb7d21484e6607c421a53f3be5 100644 (file)
@@ -775,12 +775,14 @@ static void signal_and_wait_for_handlers(pid_t own_pid, int own_tid) noexcept
                         if (Syscall::tgkill(own_pid, tid, SIGSETXID) < 0) {
                             err = errno;
                             if (ESRCH == err) { // thread already gone - noop
+                                g_thread_alive[i] = false;
                                 continue;
                             } else {
                                 abort();
                             }
                         }
                     } else if (ESRCH == err) { // thread already gone - noop
+                        g_thread_alive[i] = false;
                         continue;
                     } else {
                         abort();
@@ -792,10 +794,10 @@ static void signal_and_wait_for_handlers(pid_t own_pid, int own_tid) noexcept
         usleep(SLEEP_CONST);   // 10 ms
         --time_left;
 
-        // break if number of threads in waiting state equals to number of alive tids minus current one
+        // break if all managed alive threads are in waiting state
         if (alive_threads_have_state(1)) {
             // threads that were read some lines above are all sleeping here - BUT - could have
-            // spawned new threads between reading list from /proc and checking status with count_alive_tids_with_state()
+            // spawned new threads between reading list from /proc and checking status with alive_threads_have_state()
             // to make sure the loop can end, here we read /proc again
             check_threads(own_tid);