mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-03 15:58:02 +02:00
ifnet: avoid registering and leaking multiple file monitors
Also, need to avoid danling pointers in clear_monitor(). This was not really a problem, because we would always call cancel() before setup(). Still, it's fragile.
This commit is contained in:
parent
02deb9cffb
commit
4f4f05edc8
1 changed files with 16 additions and 12 deletions
|
|
@ -150,34 +150,38 @@ monitor_file_changes (const char *filename,
|
|||
}
|
||||
|
||||
static void
|
||||
setup_monitors (NMIfnetConnection * connection, gpointer user_data)
|
||||
setup_monitors (NMIfnetConnection *connection, gpointer user_data)
|
||||
{
|
||||
SettingsPluginIfnet *self = SETTINGS_PLUGIN_IFNET (user_data);
|
||||
SettingsPluginIfnetPrivate *priv = SETTINGS_PLUGIN_IFNET_GET_PRIVATE (self);
|
||||
|
||||
if (nm_config_get_monitor_connection_files (nm_config_get ())) {
|
||||
priv->net_monitor = monitor_file_changes (CONF_NET_FILE,
|
||||
(FileChangedFn) reload_connections,
|
||||
user_data);
|
||||
priv->wpa_monitor = monitor_file_changes (WPA_SUPPLICANT_CONF,
|
||||
(FileChangedFn) reload_connections,
|
||||
user_data);
|
||||
}
|
||||
if (!nm_config_get_monitor_connection_files (nm_config_get ()))
|
||||
return;
|
||||
|
||||
if (priv->net_monitor || priv->wpa_monitor)
|
||||
return;
|
||||
|
||||
priv->net_monitor = monitor_file_changes (CONF_NET_FILE,
|
||||
(FileChangedFn) reload_connections,
|
||||
user_data);
|
||||
priv->wpa_monitor = monitor_file_changes (WPA_SUPPLICANT_CONF,
|
||||
(FileChangedFn) reload_connections,
|
||||
user_data);
|
||||
}
|
||||
|
||||
static void
|
||||
cancel_monitors (NMIfnetConnection * connection, gpointer user_data)
|
||||
cancel_monitors (NMIfnetConnection *connection, gpointer user_data)
|
||||
{
|
||||
SettingsPluginIfnet *self = SETTINGS_PLUGIN_IFNET (user_data);
|
||||
SettingsPluginIfnetPrivate *priv = SETTINGS_PLUGIN_IFNET_GET_PRIVATE (self);
|
||||
|
||||
if (priv->net_monitor) {
|
||||
g_file_monitor_cancel (priv->net_monitor);
|
||||
g_object_unref (priv->net_monitor);
|
||||
g_clear_object (&priv->net_monitor);
|
||||
}
|
||||
if (priv->wpa_monitor) {
|
||||
g_file_monitor_cancel (priv->wpa_monitor);
|
||||
g_object_unref (priv->wpa_monitor);
|
||||
g_clear_object (&priv->wpa_monitor);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue