ifcfg-rh: add and use nm_inotify_helper_clear_watch() helper

This commit is contained in:
Thomas Haller 2017-12-01 12:09:41 +01:00
parent 8e172eb984
commit a3074ee911
2 changed files with 17 additions and 18 deletions

View file

@ -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__ */

View file

@ -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