Increase waiting time for threads to receive signal 98/295498/5
authorTomasz Swierczek <t.swierczek@samsung.com>
Mon, 10 Jul 2023 05:47:24 +0000 (07:47 +0200)
committerTomasz Swierczek <t.swierczek@samsung.com>
Mon, 10 Jul 2023 15:26:49 +0000 (15:26 +0000)
As discussed with VD engineers, thats now increased to 10 seconds.
Also, additional log with information about waiting (warning log)
was added.

Change-Id: Iaf76777af2adb2ce65f98a71349a99e1a0704cd5

src/client/client-security-manager.cpp

index 316c3ad..694ba38 100644 (file)
@@ -109,7 +109,7 @@ struct TidStatus {
 static TidStatus *g_tid_status;
 static int g_all_tid_num;
 
-#define MAX_SIG_WAIT_TIME   1000
+#define MAX_SIG_WAIT_TIME   5000 // times 2 ms thats 10 seconds
 
 // Hackish, but decided NOT to use signal SIGSETXID used by glibc
 // as this was proven to cause interference with app candidate
@@ -710,8 +710,15 @@ static inline int security_manager_sync_threads_internal(const std::string &app_
         g_threads_count -= threads_gone;
         LogDebug("number of threads already gone (signals unsent): " << threads_gone);
 
-        for (int i = MAX_SIG_WAIT_TIME; g_threads_count && i; i--)
+        unsigned counter = 0;
+        for (int i = MAX_SIG_WAIT_TIME; g_threads_count && i; i--) {
             usleep(2000);   // 2 ms
+            counter++;
+            if (counter == 500) {
+                counter = 0; // reset counter each ~1 second and add warning log
+                LogWarning("Not all threads synchronized yet, still waiting - threads left: " << g_threads_count);
+            }
+        }
 
         Syscall::sigaction(SIGNAL_NUM, &old, nullptr);