block : no longer use configend option at the conf file 13/66113/2
authorKichan Kwon <k_c.kwon@samsung.com>
Fri, 15 Apr 2016 08:27:23 +0000 (17:27 +0900)
committerKichan Kwon <k_c.kwon@samsung.com>
Mon, 18 Apr 2016 07:50:32 +0000 (16:50 +0900)
- configend is just used to inform the end of conf file

Change-Id: Ibd1bb085af9cd94d3d1601f69ed51fb8be8ede82
Signed-off-by: Kichan Kwon <k_c.kwon@samsung.com>
src/block/block.c
src/block/block.conf

index a513ae2..0ec0471 100755 (executable)
@@ -62,7 +62,7 @@ static void free_exclude_key(gpointer data)
 static void add_monitoring_path(gpointer elem, gpointer not_used)
 {
        char *monitoring_path = (char*)elem;
-       struct block_monitor_info *bmi = (struct block_monitor_info*)malloc(sizeof(struct block_monitor_info));
+       struct block_monitor_info *bmi = (struct block_monitor_info*)calloc(1, sizeof(struct block_monitor_info));
        if (!bmi) {
                _E("Failed to add monitoring path %s", monitoring_path);
                return;
@@ -131,20 +131,10 @@ static int load_block_config(struct parse_result *result, void *user_data)
                                g_strndup(result->value, strlen(result->value)),
                            GINT_TO_POINTER(1));
 
-       } else if (MATCH(result->name, "logging")) {
+       } else if (MATCH(result->name, "logging"))
                SET_CONF(block_monitor_conf->logging, atoi(result->value));
 
-       } else if (MATCH(result->name, "configend")) {
-               if (block_monitor_conf->mode)
-                       g_slist_foreach(block_monitor_list, register_monitoring_path, NULL);
-
-               if (block_monitor_conf->block_exclude_path)
-                       g_hash_table_destroy(block_monitor_conf->block_exclude_path);
-               if (block_monitor_conf->block_include_proc)
-                       g_hash_table_destroy(block_monitor_conf->block_include_proc);
-               g_slist_free(block_monitor_list);
-       }
-       return RESOURCED_ERROR_NONE;
+       return RESOURCED_ERROR_NONE;
 }
 
 static int block_prelaunch_state(void *data)
@@ -172,12 +162,15 @@ static int block_booting_done(void *data)
 {
        config_parse(BLOCK_CONF_FILE, load_block_config, NULL);
 
+       if (block_monitor_conf->mode)
+               g_slist_foreach(block_monitor_list, register_monitoring_path, NULL);
+
        return RESOURCED_ERROR_NONE;
 }
 
 static int resourced_block_init(void *data)
 {
-       block_monitor_conf = (struct block_monitor_info*)malloc(sizeof(struct block_monitor_info));
+       block_monitor_conf = (struct block_monitor_info*)calloc(1, sizeof(struct block_monitor_info));
        if (!block_monitor_conf) {
                _E("Fail to allocate memory");
                return RESOURCED_ERROR_OUT_OF_MEMORY;
@@ -196,15 +189,15 @@ static int resourced_block_exit(void *data)
        gslist_for_each_safe(block_monitor_list, iter, next, bmi) {
                block_monitor_list = g_slist_remove(block_monitor_list, bmi);
                unregister_fanotify(bmi);
-               if (bmi->block_exclude_path)
-                       g_hash_table_destroy(bmi->block_exclude_path);
-               if (bmi->block_include_proc)
-                       g_hash_table_destroy(bmi->block_include_proc);
                free(bmi);
        }
        unregister_notifier(RESOURCED_NOTIFIER_BOOTING_DONE, block_booting_done);
        unregister_notifier(RESOURCED_NOTIFIER_APP_PRELAUNCH, block_prelaunch_state);
 
+       if (!(block_monitor_conf->block_include_proc))
+               g_hash_table_destroy(block_monitor_conf->block_include_proc);
+       if (!(block_monitor_conf->block_exclude_path))
+               g_hash_table_destroy(block_monitor_conf->block_exclude_path);
        free(block_monitor_conf);
 
        return RESOURCED_ERROR_NONE;
index 57260d0..868eb38 100644 (file)
@@ -1,7 +1,6 @@
 # activate {TRUE, FALSE}
 # mode {DISABLE, ACCESS, READ, WRITE}
 # logging { DLOG = 0x1, FILE = 0x2, DB = 0x4}
-# When adding new monitor, "configend=NULL" should be included for distributing other categories.
 [MONITOR]
 activate=TRUE
 mode=WRITE
@@ -10,4 +9,3 @@ exclude=SLP_debug
 exclude_proc=mtp-responder
 exclude_proc=testmode
 logging=5
-configend=NULL