diff options
author | Hwankyu Jhun <h.jhun@samsung.com> | 2018-07-10 12:09:00 +0900 |
---|---|---|
committer | Hwankyu Jhun <h.jhun@samsung.com> | 2018-07-10 13:32:41 +0900 |
commit | 0e0746d4f31b124a7ec97eb32792eaec3e302922 (patch) | |
tree | abe4bde27402900a35b32969a300dbfbcdc4ac3d | |
parent | 526c35e7d021a1723d75de67b4649f7de426fc44 (diff) | |
download | launchpad-0e0746d4f31b124a7ec97eb32792eaec3e302922.tar.gz launchpad-0e0746d4f31b124a7ec97eb32792eaec3e302922.tar.bz2 launchpad-0e0746d4f31b124a7ec97eb32792eaec3e302922.zip |
Fix a bug about loader creation
Even though the loader processs is running, a new loader process
is started by the timeout handler.
To prevent duplication, this patch adds exceptions.
Change-Id: If47bad339e88c7d30c346131cb304b61e6d68acd
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
-rwxr-xr-x | src/launchpad.c | 46 |
1 files changed, 43 insertions, 3 deletions
diff --git a/src/launchpad.c b/src/launchpad.c index 1afa58a..c42fb33 100755 --- a/src/launchpad.c +++ b/src/launchpad.c @@ -179,6 +179,11 @@ static gboolean __handle_queuing_slots(gpointer data) return G_SOURCE_CONTINUE; } + if (cpc->timer) { + g_source_remove(cpc->timer); + cpc->timer = 0; + } + _get_cpu_idle(&total, &idle); cpc->cpu_idle_time = idle; cpc->cpu_total_time = total; @@ -191,16 +196,45 @@ static gboolean __handle_queuing_slots(gpointer data) return G_SOURCE_CONTINUE; } -static int __sequencer_add_slot(candidate_process_context_t *cpc) +static bool __sequencer_slot_is_running(candidate_process_context_t *cpc) +{ + GSource *source; + guint source_id; + + source = g_main_context_find_source_by_funcs_user_data(NULL, + (GSourceFuncs *)__handle_idle_checker, (gpointer)cpc); + if (source) { + source_id = g_source_get_id(source); + if (source_id != 0 && source_id == __sequencer.idle_checker) + return true; + } + + return false; +} + +static bool __sequencer_slot_exist(candidate_process_context_t *cpc) { GList *found; found = g_queue_find(__sequencer.queue, cpc); - if (found) { + if (found) + return true; + + return false; +} + +static int __sequencer_add_slot(candidate_process_context_t *cpc) +{ + if (__sequencer_slot_exist(cpc)) { _W("Already exists"); return -1; } + if (__sequencer_slot_is_running(cpc)) { + _W("slot(%d) is running", cpc->type); + return -1; + } + g_queue_push_tail(__sequencer.queue, cpc); return 0; @@ -619,6 +653,11 @@ static gboolean __handle_timeout_event(gpointer user_data) cpc = (candidate_process_context_t *)user_data; cpc->timer = 0; + if (cpc->pid != CANDIDATE_NONE) { + _W("Candidate(%d) process(%d) is running", cpc->type, cpc->pid); + return G_SOURCE_REMOVE; + } + __sequencer_add_slot(cpc); __sequencer_run(); return G_SOURCE_REMOVE; @@ -1778,7 +1817,8 @@ static gboolean __handle_launch_event(gpointer data) pid = __launch_directly(menu_info->appid, app_path, clifd, kb, menu_info, NULL); if (org_cpc && org_cpc->app_exists && - org_cpc->pid == CANDIDATE_NONE) { + org_cpc->pid == CANDIDATE_NONE && + !__sequencer_slot_exist(org_cpc)) { if (org_cpc->timer > 0) { g_source_remove(org_cpc->timer); org_cpc->timer = 0; |