}
}
+static void __reset_slot(candidate_process_context_t *cpc)
+{
+ if (cpc == NULL)
+ return;
+
+ cpc->send_fd = -1;
+ cpc->prepared = false;
+ cpc->pid = CANDIDATE_NONE;
+ cpc->source = 0;
+ cpc->timer = 0;
+ cpc->idle_checker = 0;
+}
+
static int __send_launchpad_loader(candidate_process_context_t *cpc,
app_pkt_t *pkt, const char *app_path, int clifd)
{
cpc->pid, app_path);
pid = cpc->pid;
- close(cpc->send_fd);
- cpc->prepared = false;
- cpc->pid = CANDIDATE_NONE;
- cpc->send_fd = -1;
- if (cpc->source > 0) {
+ if (cpc->send_fd > 0)
+ close(cpc->send_fd);
+ if (cpc->source > 0)
g_source_remove(cpc->source);
- cpc->source = 0;
- }
-
- if (cpc->timer > 0) {
+ if (cpc->timer > 0)
g_source_remove(cpc->timer);
- cpc->timer = 0;
- }
-
- if (cpc->idle_checker > 0) {
+ if (cpc->idle_checker > 0)
g_source_remove(cpc->idle_checker);
- cpc->idle_checker = 0;
- }
+ __reset_slot(cpc);
__set_timer(cpc);
return pid;
}
SECURE_LOGE("Type %d candidate process was " \
"(POLLHUP|POLLNVAL), pid: %d",
cpc->type, cpc->pid);
- close(cpc->send_fd);
-
- cpc->prepared = false;
- cpc->pid = CANDIDATE_NONE;
- cpc->send_fd = -1;
- cpc->source = 0;
+ if (cpc->send_fd > 0)
+ close(cpc->send_fd);
if (cpc->timer > 0)
g_source_remove(cpc->timer);
- cpc->timer = 0;
if (cpc->idle_checker > 0)
g_source_remove(cpc->idle_checker);
- cpc->idle_checker = 0;
+
+ __reset_slot(cpc);
+
__prepare_candidate_process(cpc->type, cpc->loader_id);
return G_SOURCE_REMOVE;
_signal_process_sigchld(&siginfo);
cpc = __find_slot_from_pid(siginfo.ssi_pid);
if (cpc != NULL) {
- cpc->prepared = false;
+ __reset_slot(cpc);
__prepare_candidate_process(cpc->type, cpc->loader_id);
}
while (iter) {
cpc = (candidate_process_context_t *)iter->data;
if (cpc->pid > 0) {
- if (cpc->source > 0) {
+ if (cpc->source > 0)
g_source_remove(cpc->source);
- cpc->source = 0;
- }
-
- if (cpc->timer > 0) {
+ if (cpc->timer > 0)
g_source_remove(cpc->timer);
- cpc->timer = 0;
- }
-
- if (cpc->idle_checker > 0) {
+ if (cpc->idle_checker > 0)
g_source_remove(cpc->idle_checker);
- cpc->idle_checker = 0;
- }
-
+ if (cpc->send_fd > 0)
+ close(cpc->send_fd);
_D("Dispose candidate process %d", cpc->pid);
__kill_process(cpc->pid);
- close(cpc->send_fd);
- cpc->prepared = false;
- cpc->pid = CANDIDATE_NONE;
- cpc->send_fd = -1;
+ __reset_slot(cpc);
__prepare_candidate_process(cpc->type, cpc->loader_id);
}
_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 && org_cpc->pid == CANDIDATE_NONE) {
if (org_cpc->timer > 0) {
g_source_remove(org_cpc->timer);
org_cpc->timer = 0;