unsigned int score;
unsigned int pss;
int cpu_check_count;
+ int on_boot_timeout;
+ guint on_boot_timer;
} candidate_process_context_t;
typedef struct {
cpc->client_channel = NULL;
cpc->timer = 0;
cpc->live_timer = 0;
+ cpc->on_boot_timer = 0;
}
static void __dispose_candidate_process(candidate_process_context_t *cpc)
g_source_remove(cpc->timer);
if (cpc->send_fd > 0)
close(cpc->send_fd);
+ if (cpc->on_boot_timer > 0)
+ g_source_remove(cpc->on_boot_timer);
__reset_slot(cpc);
}
return G_SOURCE_REMOVE;
}
+ if (cpc->pid != CANDIDATE_NONE) {
+ _W("Slot is already running. %d:%s:%d",
+ cpc->type, cpc->loader_name, cpc->pid);
+ __sequencer.idle_checker = 0;
+ __sequencer.running_cpc = NULL;
+ return G_SOURCE_REMOVE;
+ }
+
_get_cpu_idle(&total, &idle);
if (total == cpc->cpu_total_time)
total++;
return G_SOURCE_CONTINUE;
}
+static gboolean __on_boot_timeout_cb(gpointer user_data)
+{
+ candidate_process_context_t *context = user_data;
+
+ _W("type(%d), loader_name(%s)", context->type, context->loader_name);
+ context->on_boot_timer = 0;
+ if (context->pid != CANDIDATE_NONE) {
+ _E("Candidate process is already running. %d:%s:%d",
+ context->type, context->loader_name,
+ context->pid);
+ } else {
+ __prepare_candidate_process(context->type, context->loader_id);
+ context->touched = true;
+ }
+
+ return G_SOURCE_REMOVE;
+}
+
+static void __add_on_boot_timer(candidate_process_context_t *context)
+{
+ if (context->on_boot_timer != 0)
+ return;
+
+ context->on_boot_timer = g_timeout_add(context->on_boot_timeout,
+ __on_boot_timeout_cb, context);
+}
+
static int __add_idle_checker(int detection_method, GList *cur)
{
candidate_process_context_t *cpc;
continue;
}
+ if (!cpc->touched && cpc->on_boot && cpc->on_boot_timeout > 0)
+ __add_on_boot_timer(cpc);
+
if (cpc->app_check && !cpc->app_exists) {
iter = g_list_next(iter);
continue;
cpc->score = WIN_SCORE;
cpc->pss = 0;
cpc->cpu_check_count = 0;
+ cpc->on_boot_timeout = info->on_boot_timeout;
if ((cpc->deactivation_method & METHOD_OUT_OF_MEMORY) &&
__is_low_memory())
.app_exists = info->app_exists,
.is_hydra = info->is_hydra,
.app_check = info->app_check,
+ .on_boot_timeout = info->on_boot_timeout,
};
if (!strcmp(info->exe, "null")) {
#define TAG_ON_BOOT "ON_BOOT"
#define TAG_HYDRA "HYDRA"
#define TAG_APP_CHECK "APP_CHECK"
+#define TAG_ON_BOOT_TIMEOUT "ON_BOOT_TIMEOUT"
#define VAL_ON "ON"
#define VAL_OFF "OFF"
if (tok2 && strcasecmp(VAL_OFF, tok2) == 0)
cur_info->on_boot = false;
} else if (strcasecmp(TAG_HYDRA, tok1) == 0) {
- if (strcasecmp(VAL_ON, tok2) == 0) {
+ if (strcasecmp(VAL_ON, tok2) == 0)
cur_info->is_hydra = 1;
- } else {
+ else
cur_info->is_hydra = 0;
- }
} else if (strcasecmp(TAG_APP_CHECK, tok1) == 0) {
if (tok2 && strcasecmp(VAL_OFF, tok2) == 0)
cur_info->app_check = false;
+ } else if (strcasecmp(TAG_ON_BOOT_TIMEOUT, tok1) == 0) {
+ cur_info->on_boot_timeout = atoi(tok2);
}
}