summaryrefslogtreecommitdiff
path: root/vpn
diff options
context:
space:
mode:
authorJukka Rissanen <jukka.rissanen@linux.intel.com>2013-03-07 16:13:39 (GMT)
committerPatrik Flykt <patrik.flykt@linux.intel.com>2013-03-08 11:50:01 (GMT)
commite584c54cf1fb28e8f67a2983722640cbe13b49d9 (patch)
treef1abb4b3e3e4518a955c025511c5fc3fdc6fb1e9 /vpn
parent233b185bf1a8b7e9946aff88971fcecadf639dc7 (diff)
downloadconnman-e584c54cf1fb28e8f67a2983722640cbe13b49d9.zip
connman-e584c54cf1fb28e8f67a2983722640cbe13b49d9.tar.gz
connman-e584c54cf1fb28e8f67a2983722640cbe13b49d9.tar.bz2
vpn-config: Ignore IN_CREATE as IN_MODIFY is called anyway
Inotify will send modify event after create event when user has copied the config file into config directory. Because of this it is useless to act on create event. As a bonus we avoid create/modify/create loop that was earlier done in the modify event handling code.
Diffstat (limited to 'vpn')
-rw-r--r--vpn/vpn-config.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/vpn/vpn-config.c b/vpn/vpn-config.c
index 1ece7e9..a1a2ed5 100644
--- a/vpn/vpn-config.c
+++ b/vpn/vpn-config.c
@@ -539,28 +539,40 @@ static void config_notify_handler(struct inotify_event *event,
}
if (event->mask & IN_CREATE)
- create_config(ident);
+ return;
+
+ if (event->mask & IN_DELETE) {
+ g_hash_table_remove(config_table, ident);
+ return;
+ }
if (event->mask & IN_MODIFY) {
struct vpn_config *config;
+ char *path = get_dir();
config = g_hash_table_lookup(config_table, ident);
if (config != NULL) {
- char *path = get_dir();
-
g_hash_table_remove_all(config->provider_table);
load_config(config, path, REMOVE);
/* Re-scan the config file for any changes */
g_hash_table_remove_all(config->provider_table);
load_config(config, path, ADD);
-
- g_free(path);
+ } else {
+ /*
+ * Inotify will send create event followed by modify
+ * event for any config file that is copied to
+ * monitored directory. So in practice we should just
+ * ignore the create event and trust only the modify
+ * one in order to avoid create/remove/create loop
+ */
+ config = create_config(ident);
+ if (config != NULL)
+ load_config(config, path, ADD);
}
- }
- if (event->mask & IN_DELETE)
- g_hash_table_remove(config_table, ident);
+ g_free(path);
+ }
}
int __vpn_config_init(void)