diff --git a/src/settings/plugins/ifcfg-rh/nm-ifcfg-connection.c b/src/settings/plugins/ifcfg-rh/nm-ifcfg-connection.c index d4e3cf704f..ae6f48356e 100644 --- a/src/settings/plugins/ifcfg-rh/nm-ifcfg-connection.c +++ b/src/settings/plugins/ifcfg-rh/nm-ifcfg-connection.c @@ -68,6 +68,8 @@ typedef struct { gulong devtimeout_link_changed_handler; guint devtimeout_timeout_id; + + NMInotifyHelper *inotify_helper; } NMIfcfgConnectionPrivate; enum { @@ -85,6 +87,14 @@ enum { static guint signals[LAST_SIGNAL] = { 0 }; +static NMInotifyHelper * +_get_inotify_helper (NMIfcfgConnectionPrivate *priv) +{ + if (!priv->inotify_helper) + priv->inotify_helper = g_object_ref (nm_inotify_helper_get ()); + return priv->inotify_helper; +} + static gboolean devtimeout_ready (gpointer user_data) { @@ -265,7 +275,7 @@ path_watch_stop (NMIfcfgConnection *self) NMIfcfgConnectionPrivate *priv = NM_IFCFG_CONNECTION_GET_PRIVATE (self); NMInotifyHelper *ih; - ih = nm_inotify_helper_get (); + ih = _get_inotify_helper (priv); if (priv->ih_event_id) { g_signal_handler_disconnect (ih, priv->ih_event_id); @@ -319,7 +329,9 @@ filename_changed (GObject *object, priv->route6file = utils_get_route6_path (ifcfg_path); if (nm_config_get_monitor_connection_files (nm_config_get ())) { - NMInotifyHelper *ih = nm_inotify_helper_get (); + NMInotifyHelper *ih; + + ih = _get_inotify_helper (priv); priv->ih_event_id = g_signal_connect (ih, "event", G_CALLBACK (files_changed_cb), self); priv->file_wd = nm_inotify_helper_add_watch (ih, ifcfg_path); @@ -514,6 +526,8 @@ dispose (GObject *object) priv->devtimeout_timeout_id = 0; } + g_clear_object (&priv->inotify_helper); + G_OBJECT_CLASS (nm_ifcfg_connection_parent_class)->dispose (object); }