Improve stability 05/104705/9
authorKichan Kwon <k_c.kwon@samsung.com>
Wed, 14 Dec 2016 06:25:03 +0000 (15:25 +0900)
committerKichan Kwon <k_c.kwon@samsung.com>
Mon, 19 Dec 2016 04:07:45 +0000 (13:07 +0900)
- No more update user list when it is needed
  - In current, there is no scenario about adding new users
- Wait data thread for writing before storing to HEART DB
- Remove program list of subordinated app
- Check array size before remove it

Change-Id: If08ad5b55faf1103f20c2f2d379b5d7dc53d9f98
Signed-off-by: Kichan Kwon <k_c.kwon@samsung.com>
src/common/userinfo-list.c
src/heart/heart-cpu.c
src/heart/logging.c

index 57e769b..125fe97 100644 (file)
@@ -125,10 +125,15 @@ const char *userinfo_find_home_dir(uid_t uid)
 
 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)
index 672ed8e..10a68a9 100644 (file)
@@ -803,7 +803,8 @@ void heart_cpu_update(struct logging_table_form *data, void *user_data)
                        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);
index 5fcf83b..6a5a402 100644 (file)
@@ -1528,6 +1528,34 @@ static int logging_thread_create(void)
        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 */
@@ -1619,13 +1647,7 @@ int logging_exit(void *data)
        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);