diff options
author | Hwankyu Jhun <h.jhun@samsung.com> | 2018-07-17 09:09:40 +0900 |
---|---|---|
committer | Hwankyu Jhun <h.jhun@samsung.com> | 2018-07-17 09:41:19 +0900 |
commit | b8d4da0e3807461656eafa9969808ea25bccf841 (patch) | |
tree | dc3f933ce2fd4df7f5e3bd179b13154096dacd91 | |
parent | 6b08e248e010dbf65a877ea6487d5a4c2910f2a3 (diff) | |
download | launchpad-b8d4da0e3807461656eafa9969808ea25bccf841.tar.gz launchpad-b8d4da0e3807461656eafa9969808ea25bccf841.tar.bz2 launchpad-b8d4da0e3807461656eafa9969808ea25bccf841.zip |
Fix a bug about checking slot state
Change-Id: Ia66d26ca5eb80b2fb820d50c3ff13cb531ccdadd
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
-rwxr-xr-x | src/launchpad.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/src/launchpad.c b/src/launchpad.c index c42fb33..be32c28 100755 --- a/src/launchpad.c +++ b/src/launchpad.c @@ -109,6 +109,7 @@ typedef struct { GQueue *queue; guint timer; guint idle_checker; + candidate_process_context_t *running_cpc; } sequencer; struct app_launch_arg { @@ -169,7 +170,7 @@ static gboolean __handle_queuing_slots(gpointer data) cpc = (candidate_process_context_t *)g_queue_pop_head( __sequencer.queue); if (!cpc) { - LOGE("Critical error!"); + _E("Critical error!"); __sequencer.timer = 0; return G_SOURCE_REMOVE;; } @@ -184,12 +185,19 @@ static gboolean __handle_queuing_slots(gpointer data) cpc->timer = 0; } + if (cpc->pid != CANDIDATE_NONE) { + _W("The slot(%d) is already running. pid(%d)", + cpc->type, cpc->pid); + return G_SOURCE_CONTINUE; + } + _get_cpu_idle(&total, &idle); cpc->cpu_idle_time = idle; cpc->cpu_total_time = total; __sequencer.idle_checker = g_timeout_add(CPU_CHECKER_TIMEOUT, __handle_idle_checker, cpc); + __sequencer.running_cpc = cpc; _D("[__SEQUENCER__] Add idle checker. Type(%d)", cpc->type); @@ -198,16 +206,8 @@ static gboolean __handle_queuing_slots(gpointer data) 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; - } + if (__sequencer.running_cpc == cpc) + return true; return false; } @@ -1358,6 +1358,7 @@ static gboolean __handle_idle_checker(gpointer data) if (!data) { _E("Critical error!"); __sequencer.idle_checker = 0; + __sequencer.running_cpc = NULL; return G_SOURCE_REMOVE; } @@ -1365,12 +1366,14 @@ static gboolean __handle_idle_checker(gpointer data) if (!cpc->app_exists) { _W("The application is not installed. Type(%d)", cpc->type); __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. Type(%d)", cpc->type); __sequencer.idle_checker = 0; + __sequencer.running_cpc = NULL; return G_SOURCE_REMOVE; } @@ -1386,6 +1389,7 @@ static gboolean __handle_idle_checker(gpointer data) __prepare_candidate_process(cpc->type, cpc->loader_id); cpc->touched = true; __sequencer.idle_checker = 0; + __sequencer.running_cpc = NULL; return G_SOURCE_REMOVE; } |