const GArray *userinfo_get_list(void)
{
- if (userinfo_update_list() == RESOURCED_ERROR_NONE)
- return user_list;
- else
- return NULL;
+ return user_list;
+}
+
+static void __attribute__ ((constructor)) userinfo_init(void)
+{
+ if (userinfo_update_list() != RESOURCED_ERROR_NONE) {
+ _E("Failed to init user list");
+ user_list = NULL;
+ }
}
static void __attribute__ ((destructor)) userinfo_exit(void)
search->utime = 0;
search->stime = 0;
/* hashtable sliding : remove last node and make new one */
- g_array_remove_index(search->cpu_info, CPU_ARRAY_MAX - 1);
+ if (search->cpu_info->len == CPU_ARRAY_MAX)
+ g_array_remove_index(search->cpu_info, CPU_ARRAY_MAX - 1);
g_array_prepend_val(search->cpu_info, ci);
}
ret = pthread_mutex_unlock(&heart_cpu_mutex);
return ret;
}
+static void logging_thread_stop(void)
+{
+ /* Delete timer invoking work(update,write) function */
+ ecore_timer_del(logging_update_timer);
+ logging_update_timer = NULL;
+
+ ecore_timer_del(logging_data_timer);
+ logging_data_timer = NULL;
+
+ /* Wait thread for working
+ *
+ * We can wait thread for finishing work by requesting lock
+ * because thread locks before working and unlocks after
+ *
+ * Meanwhile, in this time, timer is deleted
+ * so thread no more works though it is unlocked
+ */
+ if (pthread_mutex_lock(&logging_update_mutex))
+ _E("Failed to pthread_mutex_lock");
+ if (pthread_mutex_unlock(&logging_update_mutex))
+ _E("Failed to pthread_mutex_unlock");
+
+ if (pthread_mutex_lock(&logging_data_mutex))
+ _E("Failed to pthread_mutex_lock");
+ if (pthread_mutex_unlock(&logging_data_mutex))
+ _E("Failed to pthread_mutex_unlock");
+}
+
static int logging_poweroff(void *data)
{
/* flush module cache */
int i;
struct logging_module *module;
- /* update timer delete */
- ecore_timer_del(logging_update_timer);
- logging_update_timer = NULL;
-
- /* delete data_timer */
- ecore_timer_del(logging_data_timer);
- logging_data_timer = NULL;
+ logging_thread_stop();
unregister_notifier(RESOURCED_NOTIFIER_LOGGING_START, logging_start);
unregister_notifier(RESOURCED_NOTIFIER_POWER_OFF, logging_poweroff);