Add ON_BOOT tag for skipping loader 47/155347/1
authorJunghoon Park <jh9216.park@samsung.com>
Fri, 13 Oct 2017 03:17:09 +0000 (12:17 +0900)
committerJunghoon Park <jh9216.park@samsung.com>
Fri, 13 Oct 2017 03:21:28 +0000 (12:21 +0900)
- To skip making some candidate processes right after booting, the new tag was added

Change-Id: If0eebf5920f0bdff2b7e2db97c8fc8a738cda4c2
Signed-off-by: Junghoon Park <jh9216.park@samsung.com>
inc/loader_info.h
src/launchpad.c
src/loader_info.c

index 2e5a21d..a3c58bb 100644 (file)
@@ -39,6 +39,7 @@ typedef struct _loader_info {
        bundle *extra;
        int cpu_threshold_max;
        int cpu_threshold_min;
+       bool on_boot;
 } loader_info_t;
 
 GList *_loader_info_load(const char *path);
index 8288d4c..fc7d8bb 100755 (executable)
@@ -85,6 +85,7 @@ typedef struct {
        int threshold_max;
        int threshold_min;
        int cur_event;
+       bool on_boot;
 } candidate_process_context_t;
 
 typedef struct {
@@ -115,7 +116,7 @@ static GList *launcher_info_list;
 static candidate_process_context_t *__add_slot(int type, int loader_id,
                int caller_pid, const char *loader_path, const char *extra,
                int detection_method, int timeout_val,
-               int threshold_max, int threshold_min);
+               int threshold_max, int threshold_min, bool on_boot);
 static int __remove_slot(int type, int loader_id);
 static int __add_default_slots(void);
 static gboolean __handle_idle_checker(gpointer data);
@@ -1184,6 +1185,9 @@ static int __add_idle_checker(int detection_method, GList *cur)
                        continue;
                }
 
+               if (detection_method == EVENT_BOOTING && !cpc->on_boot)
+                       continue;
+
                if (cpc->pid == CANDIDATE_NONE &&
                                (detection_method == EVENT_BOOTING ||
                                 (cpc->detection_method & detection_method))) {
@@ -1236,7 +1240,8 @@ static int __dispatch_cmd_add_loader(bundle *kb)
                cpc = __add_slot(LAUNCHPAD_TYPE_DYNAMIC, lid, atoi(caller_pid),
                                add_slot_str, extra,
                                METHOD_TIMEOUT | METHOD_VISIBILITY, 2000,
-                               DEFAULT_CPU_THRESHOLD_MAX, DEFAULT_CPU_THRESHOLD_MIN);
+                               DEFAULT_CPU_THRESHOLD_MAX, DEFAULT_CPU_THRESHOLD_MIN,
+                               false);
                __set_timer(cpc);
                return lid;
        }
@@ -1287,7 +1292,8 @@ static bool __is_hw_acc(const char *hwacc)
 }
 
 static candidate_process_context_t *__find_available_slot(const char *hwacc,
-               const char *app_type, const char *loader_name)
+               const char *app_type, const char *loader_name,
+               candidate_process_context_t **org_cpc)
 {
        int type;
        candidate_process_context_t *cpc;
@@ -1306,6 +1312,8 @@ static candidate_process_context_t *__find_available_slot(const char *hwacc,
        if (!cpc)
                return NULL;
 
+       *org_cpc = cpc;
+
        if (cpc->prepared)
                return cpc;
 
@@ -1335,6 +1343,7 @@ static gboolean __handle_launch_event(gpointer data)
        app_pkt_t *pkt = NULL;
        appinfo_t *menu_info = NULL;
        candidate_process_context_t *cpc = NULL;
+       candidate_process_context_t *org_cpc = NULL;
        const char *app_path = NULL;
        int pid = -1;
        int clifd = -1;
@@ -1443,7 +1452,7 @@ static gboolean __handle_launch_event(gpointer data)
                if (loader_id <= PAD_LOADER_ID_STATIC) {
                        cpc = __find_available_slot(menu_info->hwacc,
                                        menu_info->app_type,
-                                       menu_info->loader_name);
+                                       menu_info->loader_name, &org_cpc);
                } else {
                        type = LAUNCHPAD_TYPE_DYNAMIC;
                        cpc = __find_slot(type, loader_id);
@@ -1462,6 +1471,19 @@ static gboolean __handle_launch_event(gpointer data)
                _W("Launch directly %d %p", loader_id, cpc);
                pid = __launch_directly(menu_info->appid, app_path, clifd, kb,
                                menu_info, NULL);
+               if (org_cpc) {
+                       if (org_cpc->timer > 0) {
+                               g_source_remove(org_cpc->timer);
+                               org_cpc->timer = 0;
+                       }
+
+                       if (org_cpc->idle_checker > 0) {
+                               g_source_remove(org_cpc->idle_checker);
+                               org_cpc->idle_checker = 0;
+                       }
+
+                       __set_timer(org_cpc);
+               }
        } else {
                _W("Launch %d type process", cpc->type);
                pid = __send_launchpad_loader(cpc, pkt, app_path, clifd);
@@ -1492,7 +1514,7 @@ end:
 static candidate_process_context_t *__add_slot(int type, int loader_id,
                int caller_pid, const char *loader_path,
                const char *loader_extra, int detection_method,
-               int timeout_val, int threshold_max, int threshold_min)
+               int timeout_val, int threshold_max, int threshold_min, bool on_boot)
 {
        candidate_process_context_t *cpc;
        int fd = -1;
@@ -1525,6 +1547,7 @@ static candidate_process_context_t *__add_slot(int type, int loader_id,
        cpc->threshold = threshold_max;
        cpc->threshold_max = threshold_max;
        cpc->threshold_min = threshold_min;
+       cpc->on_boot = on_boot;
 
        fd = __listen_candidate_process(cpc->type, cpc->loader_id);
        if (fd == -1) {
@@ -1719,7 +1742,7 @@ static void __add_slot_from_info(gpointer data, gpointer user_data)
                cpc = __add_slot(LAUNCHPAD_TYPE_USER + user_slot_offset,
                                PAD_LOADER_ID_DIRECT,
                                0, info->exe, NULL, 0, 0,
-                               info->cpu_threshold_max, info->cpu_threshold_min);
+                               info->cpu_threshold_max, info->cpu_threshold_min, false);
                if (cpc == NULL)
                        return;
 
@@ -1739,7 +1762,7 @@ static void __add_slot_from_info(gpointer data, gpointer user_data)
                                PAD_LOADER_ID_STATIC,
                                0, info->exe, (char *)extra,
                                info->detection_method, info->timeout_val,
-                               info->cpu_threshold_max, info->cpu_threshold_min);
+                               info->cpu_threshold_max, info->cpu_threshold_min, info->on_boot);
                if (cpc == NULL)
                        return;
 
index bf9dc49..5d2e327 100644 (file)
@@ -37,6 +37,7 @@
 #define TAG_HW_ACC             "HW_ACC"
 #define TAG_CPU_THRESHOLD_MAX  "CPU_THRESHOLD_MAX"
 #define TAG_CPU_THRESHOLD_MIN  "CPU_THRESHOLD_MIN"
+#define TAG_ON_BOOT            "ON_BOOT"
 #define VAL_ON                 "ON"
 #define VAL_OFF                        "OFF"
 #define VAL_METHOD_TIMEOUT     "TIMEOUT"
@@ -65,6 +66,7 @@ static loader_info_t *__create_loader_info()
        info->extra = bundle_create();
        info->cpu_threshold_max = DEFAULT_CPU_THRESHOLD_MAX;
        info->cpu_threshold_min = DEFAULT_CPU_THRESHOLD_MIN;
+       info->on_boot = true;
 
        return info;
 }
@@ -228,6 +230,9 @@ static GList *__parse_file(GList *list, const char *path)
                        cur_info->cpu_threshold_max = atoi(tok2);
                } else if (strcasecmp(TAG_CPU_THRESHOLD_MIN, tok1) == 0) {
                        cur_info->cpu_threshold_min = atoi(tok2);
+               } else if (strcasecmp(TAG_ON_BOOT, tok1) == 0) {
+                       if (tok2 && strcasecmp(VAL_OFF, tok2) == 0)
+                               cur_info->on_boot = false;
                }
        }