Add a new option to the loader configuration 97/289297/4
authorHwankyu Jhun <h.jhun@samsung.com>
Mon, 6 Mar 2023 04:46:44 +0000 (04:46 +0000)
committerHwanKyu Jhun <h.jhun@samsung.com>
Mon, 6 Mar 2023 05:42:53 +0000 (05:42 +0000)
The "CONDITION_PATH_EXISTS" option is added to the loader configuration.
The option is for the "ON_BOOT_TIMEOUT" option. If the path does not exist,
the launchpad does not prepare the candidate process. And, the launchpad
adds a timer to wait until the path exists. The interval of the timer is 100 ms.

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

index 6d44b1d1cca1ed012b006ff8f3421799714b6810..5c2d7c76534f95d9f6798cb413956e3f87283ece 100644 (file)
@@ -56,6 +56,7 @@ typedef struct _loader_info {
        bool app_check;
        int on_boot_timeout;
        int sched_priority;
+       GList *condition_path_exists;
 } loader_info_t;
 
 typedef void (*loader_info_foreach_cb)(loader_info_t *info, void *data);
index 58de327c7ad90dcae7cf80d91bd9ec7812cfaecc..788cadbde1a4d59809cd8ba149424218419ab0de 100644 (file)
@@ -39,6 +39,7 @@ typedef struct slot_info_s {
        bool app_check;
        int on_boot_timeout;
        int sched_priority;
+       GList *condition_path_exists;
 } slot_info_t;
 
 #endif /* __SLOT_INFO_H__ */
index 8c9dfb4bd02765fd4360e78e977ffe60324a865b..0d96bd96f743b4c184684b4d459dfc5148c2c34b 100644 (file)
@@ -132,6 +132,7 @@ typedef struct {
        int on_boot_timeout;
        guint on_boot_timer;
        int sched_priority;
+       GList *condition_path_exists;
 } candidate_process_context_t;
 
 typedef struct {
@@ -1867,6 +1868,8 @@ 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;
@@ -1875,6 +1878,21 @@ 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);
+                               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);
                context->touched = true;
        }
@@ -1995,6 +2013,7 @@ static int __dispatch_cmd_add_loader(bundle *kb)
        slot_info.app_check = true;
        slot_info.on_boot_timeout = 0;
        slot_info.sched_priority = 0;
+       slot_info.condition_path_exists = NULL;
 
        cpc = __add_slot(&slot_info);
        free(loader_name);
@@ -2055,6 +2074,7 @@ static int __dispatch_cmd_add_app_defined_loader(bundle *kb)
                slot_info.app_check = true;
                slot_info.on_boot_timeout = 0;
                slot_info.sched_priority = 0;
+               slot_info.condition_path_exists = NULL;
 
                cpc = __add_slot(&slot_info);
                bundle_free_encoded_rawdata(&extra);
@@ -2744,6 +2764,7 @@ static candidate_process_context_t *__create_slot(slot_info_t *info)
        cpc->cpu_check_count = 0;
        cpc->on_boot_timeout = info->on_boot_timeout;
        cpc->sched_priority = info->sched_priority;
+       cpc->condition_path_exists = g_list_copy(info->condition_path_exists);
 
        if ((cpc->deactivation_method & METHOD_OUT_OF_MEMORY) &&
                        __is_low_memory())
@@ -3071,6 +3092,7 @@ static void __add_slot_from_info(gpointer data, gpointer user_data)
                .app_check = info->app_check,
                .on_boot_timeout = info->on_boot_timeout,
                .sched_priority = info->sched_priority,
+               .condition_path_exists = info->condition_path_exists,
        };
 
        if (!strcmp(info->exe, "null")) {
index c43986f2f586e875451a7a86cf5335a3ce6ace28..1bf1abbd38850b2500389241cb528a92da32421a 100644 (file)
@@ -45,6 +45,7 @@
 #define TAG_APP_CHECK                   "APP_CHECK"
 #define TAG_ON_BOOT_TIMEOUT             "ON_BOOT_TIMEOUT"
 #define TAG_SCHED_PRIORITY             "SCHED_PRIORITY"
+#define TAG_CONDITION_PATH_EXISTS      "CONDITION_PATH_EXISTS"
 
 #define VAL_ON                         "ON"
 #define VAL_OFF                                "OFF"
@@ -164,6 +165,19 @@ static void __parse_app_types(loader_info_t *info, char *line)
        }
 }
 
+static void __parse_condition_path_exists(loader_info_t *info, char *line)
+{
+       char *token;
+       char *savedptr;
+
+       token = strtok_r(line, " |\t\r\n", &savedptr);
+       while (token) {
+               info->condition_path_exists = g_list_append(
+                               info->condition_path_exists, strdup(token));
+               token = strtok_r(NULL, " |\t\r\n", &savedptr);
+       }
+}
+
 static void __parse_extra(loader_info_t *info, char *line)
 {
        char *tok1 = NULL;
@@ -319,6 +333,8 @@ static GList *__parse_file(GList *list, const char *path)
                                cur_info->sched_priority = -20;
                        else if (cur_info->sched_priority > 19)
                                cur_info->sched_priority = 19;
+               } else if (strcasecmp(TAG_CONDITION_PATH_EXISTS, tok1) == 0) {
+                       __parse_condition_path_exists(cur_info, buf);
                }
        }