config: Check if we need to rescan the config file for any changes
[framework/connectivity/connman.git] / src / config.c
index b304645..5363dc3 100644 (file)
@@ -629,9 +629,20 @@ static gboolean inotify_data(GIOChannel *channel, GIOCondition cond,
 
                        config = g_hash_table_lookup(config_table, ident);
                        if (config != NULL) {
+                               int ret;
+
                                g_hash_table_remove_all(config->service_table);
                                load_config(config);
-                               __connman_service_provision_changed(ident);
+                               ret = __connman_service_provision_changed(ident);
+                               if (ret > 0) {
+                                       /*
+                                        * Re-scan the config file for any
+                                        * changes
+                                        */
+                                       g_hash_table_remove_all(config->service_table);
+                                       load_config(config);
+                                       __connman_service_provision_changed(ident);
+                               }
                        }
                }
 
@@ -873,6 +884,7 @@ int __connman_config_provision_service_ident(struct connman_service *service,
 {
        enum connman_service_type type;
        struct connman_config *config;
+       int ret = 0;
 
        DBG("service %p", service);
 
@@ -910,17 +922,19 @@ int __connman_config_provision_service_ident(struct connman_service *service,
                        DBG("found %d ident %s file %s entry %s", found, ident,
                                                                file, entry);
 
-                       if (found == FALSE)
+                       if (found == FALSE) {
                                /*
                                 * The entry+8 will skip "service_" prefix
                                 */
                                g_hash_table_remove(config->service_table,
                                                entry + 8);
+                               ret = 1;
+                       }
                }
 
                g_hash_table_foreach(config->service_table,
                                                provision_service, service);
        }
 
-       return 0;
+       return ret;
 }