summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2017-12-01 12:09:41 +0100
committerThomas Haller <thaller@redhat.com>2017-12-05 21:24:22 +0100
commit5b210209b822ff09e349efba5f5a6161d07737f7 (patch)
tree3695a4f0d4df24faafc11fdfebce02ba790c3c86
parent124c82d851906185468d320a5cc8d8e35cde8878 (diff)
downloadNetworkManager-5b210209b822ff09e349efba5f5a6161d07737f7.tar.gz
ifcfg-rh: add and use nm_inotify_helper_clear_watch() helper
(cherry picked from commit a3074ee91160993f69bb83fd16b2cede46030405)
-rw-r--r--src/settings/plugins/ifcfg-rh/nm-inotify-helper.h13
-rw-r--r--src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-connection.c22
2 files changed, 17 insertions, 18 deletions
diff --git a/src/settings/plugins/ifcfg-rh/nm-inotify-helper.h b/src/settings/plugins/ifcfg-rh/nm-inotify-helper.h
index 2715f3eec5..b887ae378a 100644
--- a/src/settings/plugins/ifcfg-rh/nm-inotify-helper.h
+++ b/src/settings/plugins/ifcfg-rh/nm-inotify-helper.h
@@ -43,4 +43,17 @@ int nm_inotify_helper_add_watch (NMInotifyHelper *helper, const char *path);
void nm_inotify_helper_remove_watch (NMInotifyHelper *helper, int wd);
+static inline gboolean
+nm_inotify_helper_clear_watch (NMInotifyHelper *helper, int *wd)
+{
+ int x;
+
+ if (wd && ((x = *wd) >= 0)) {
+ *wd = -1;
+ nm_inotify_helper_remove_watch (helper, x);
+ return TRUE;
+ }
+ return FALSE;
+}
+
#endif /* __NM_INOTIFY_HELPER_H__ */
diff --git a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-connection.c b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-connection.c
index c8712f1833..5d3428d6bf 100644
--- a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-connection.c
+++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-connection.c
@@ -220,28 +220,14 @@ path_watch_stop (NMIfcfgConnection *self)
nm_clear_g_signal_handler (priv->inotify_helper, &priv->ih_event_id);
- if (priv->file_wd >= 0) {
- nm_inotify_helper_remove_watch (priv->inotify_helper, priv->file_wd);
- priv->file_wd = -1;
- }
+ nm_inotify_helper_clear_watch (priv->inotify_helper, &priv->file_wd);
+ nm_inotify_helper_clear_watch (priv->inotify_helper, &priv->keyfile_wd);
+ nm_inotify_helper_clear_watch (priv->inotify_helper, &priv->routefile_wd);
+ nm_inotify_helper_clear_watch (priv->inotify_helper, &priv->route6file_wd);
nm_clear_g_free (&priv->keyfile);
- if (priv->keyfile_wd >= 0) {
- nm_inotify_helper_remove_watch (priv->inotify_helper, priv->keyfile_wd);
- priv->keyfile_wd = -1;
- }
-
nm_clear_g_free (&priv->routefile);
- if (priv->routefile_wd >= 0) {
- nm_inotify_helper_remove_watch (priv->inotify_helper, priv->routefile_wd);
- priv->routefile_wd = -1;
- }
-
nm_clear_g_free (&priv->route6file);
- if (priv->route6file_wd >= 0) {
- nm_inotify_helper_remove_watch (priv->inotify_helper, priv->route6file_wd);
- priv->route6file_wd = -1;
- }
}
static void