Check file existence 16/290816/1
authorHwankyu Jhun <h.jhun@samsung.com>
Mon, 3 Apr 2023 23:04:03 +0000 (23:04 +0000)
committerHwankyu Jhun <h.jhun@samsung.com>
Mon, 3 Apr 2023 23:04:03 +0000 (23:04 +0000)
When checking cpu idle, the launchpad checks whether the file is ready or not.
If it's not ready, the launchpad skips the loader creation.

Change-Id: Ide2f9067e5930ecb7d319f0b196659ee42b380fc
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/launchpad-process-pool/src/launchpad.c

index c18c158fa602e80b975d58325874bfd3b934fbb9..8f1bd483a6da90ecaa5e210aaa4b7edb81df6d5d 100644 (file)
@@ -1805,6 +1805,27 @@ static void __update_threshold(candidate_process_context_t *cpc, float delta)
                        cpc->type, delta, pos, cpc->threshold);
 }
 
+static bool __is_file_ready(candidate_process_context_t *context)
+{
+       const char *path;
+       GList *iter;
+
+       iter = context->condition_path_exists;
+       while (iter != NULL) {
+               path = iter->data;
+               iter = g_list_next(iter);
+               if (access(path, F_OK) != 0) {
+                       _D("%s does not exist", path);
+                       return false;
+               }
+
+               context->condition_path_exists = g_list_remove(
+                               context->condition_path_exists, path);
+       }
+
+       return true;
+}
+
 static gboolean __handle_idle_checker(gpointer data)
 {
        unsigned long long total = 0;
@@ -1828,6 +1849,13 @@ static gboolean __handle_idle_checker(gpointer data)
                return G_SOURCE_REMOVE;
        }
 
+       if (!__is_file_ready(cpc)) {
+               _W("file is not ready");
+               __sequencer.idle_checker = 0;
+               __sequencer.running_cpc = NULL;
+               return G_SOURCE_REMOVE;
+       }
+
        if (cpc->state != CANDIDATE_PROCESS_STATE_RUNNING) {
                _W("Slot state is not running. loader(%s:%d)",
                                cpc->loader_name, cpc->type);
@@ -1882,8 +1910,6 @@ static gboolean __handle_idle_checker(gpointer data)
 static gboolean __on_boot_timeout_cb(gpointer user_data)
 {
        candidate_process_context_t *context = user_data;
-       const char *path;
-       GList *iter;
 
        _W("type(%d), loader_name(%s)", context->type, context->loader_name);
        context->on_boot_timer = 0;
@@ -1892,19 +1918,10 @@ static gboolean __on_boot_timeout_cb(gpointer user_data)
                                context->type, context->loader_name,
                                context->pid);
        } else {
-               iter = context->condition_path_exists;
-               while (iter != NULL) {
-                       path = (char *)iter->data;
-                       iter = g_list_next(iter);
-                       if (access(path, F_OK) != 0) {
-                               _D("%s does not exist", path);
+               if (!__is_file_ready(context)) {
                                context->on_boot_timer = g_timeout_add(100,
                                                __on_boot_timeout_cb, context);
                                return G_SOURCE_REMOVE;
-                       }
-
-                       context->condition_path_exists = g_list_remove(
-                                       context->condition_path_exists, path);
                }
 
                __prepare_candidate_process(context->type, context->loader_id);