From 979cea589c8ac2bbf593e3cf1b8d4510921dbc8a Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Mon, 16 Jan 2023 23:27:29 +0000 Subject: [PATCH] Add retrying count check for waiting threads If the retyring count is exceeded, the candidate process stops to wait for threads ready. The maximum retrying count is 600. In the worst case, the candidate process can be waitted until 30 seconds. Change-Id: I4c73674c9f783499af1087c3855f56205a52a6ad Signed-off-by: Hwankyu Jhun --- src/lib/launchpad/src/launchpad_lib.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/lib/launchpad/src/launchpad_lib.c b/src/lib/launchpad/src/launchpad_lib.c index af20cae..0c7dd27 100644 --- a/src/lib/launchpad/src/launchpad_lib.c +++ b/src/lib/launchpad/src/launchpad_lib.c @@ -404,7 +404,9 @@ static unsigned int __get_thread_count(void) static void __wait_for_threads(unsigned int threads) { +#define MAX_RETRYING_COUNT 600 unsigned int thread_count; + unsigned int retrying_count = 0; if (threads <= 1) return; @@ -412,13 +414,16 @@ static void __wait_for_threads(unsigned int threads) _W("Thread count = %u", threads); do { thread_count = __get_thread_count(); - _D("Current thread count = %u", thread_count); - if (thread_count >= threads) - break; + if (thread_count >= threads) { + _E("Threads(%u) are ready", thread_count); + return; + } + _D("Current thread count = %u", thread_count); usleep(50 * 1000); - } while (threads != thread_count); - _E("Threads(%u) are ready", thread_count); + retrying_count++; + } while (retrying_count < MAX_RETRYING_COUNT); + _E("Maximum retrying count exceeded"); } static int __before_loop(int argc, char **argv) -- 2.7.4