diff options
author | Dan Williams <dcbw@redhat.com> | 2013-08-08 15:54:32 -0500 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2013-08-09 00:54:58 -0500 |
commit | b5170903c0c5bdb5fb3820822aa0d57b3e11cf8f (patch) | |
tree | dc0d770674141d22c809a53655515bdb92d1a9b1 /src/settings/plugins/ifcfg-rh | |
parent | dd9cf657ef1f9d5909dad2eb697098715325fecf (diff) | |
download | NetworkManager-b5170903c0c5bdb5fb3820822aa0d57b3e11cf8f.tar.gz |
settings: correctly handle connection deletion after unsaved and monitor-connection-files
Plugins that could save connections to disk previously depended on inotify
events from the kernel to know when to signal connection removal; that is
in response to a 'delete' request they would unlink the backing filesystem
resources, get the inotify signal, and cause NM_SETTINGS_CONNECTION_REMOVED
to be emitted.
Unsaved connections don't have any backing resources, so they would never
get the signal emitted, and NMSettings would never forget about them.
Also, when monitor-connection-files=false in the configuration, obviously
the inotify signals will never come in because they aren't set up.
Given that we can no longer rely on inotify, it's best to just explicitly
send out the NM_SETTINGS_CONNECTION_REMOVED signal whenever a connection
is deleted via the D-Bus interface or internally.
Diffstat (limited to 'src/settings/plugins/ifcfg-rh')
-rw-r--r-- | src/settings/plugins/ifcfg-rh/plugin.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/settings/plugins/ifcfg-rh/plugin.c b/src/settings/plugins/ifcfg-rh/plugin.c index b7a8751943..dbfc496fd4 100644 --- a/src/settings/plugins/ifcfg-rh/plugin.c +++ b/src/settings/plugins/ifcfg-rh/plugin.c @@ -115,6 +115,13 @@ connection_ifcfg_changed (NMIfcfgConnection *connection, gpointer user_data) connection_new_or_changed (plugin, path, connection, NULL); } +static void +connection_removed_cb (NMSettingsConnection *obj, gpointer user_data) +{ + g_hash_table_remove (SC_PLUGIN_IFCFG_GET_PRIVATE (user_data)->connections, + nm_connection_get_uuid (NM_CONNECTION (obj))); +} + static NMIfcfgConnection * _internal_new_connection (SCPluginIfcfg *self, const char *path, @@ -148,6 +155,9 @@ _internal_new_connection (SCPluginIfcfg *self, g_strdup (nm_connection_get_uuid (NM_CONNECTION (connection))), connection); PLUGIN_PRINT (IFCFG_PLUGIN_NAME, " read connection '%s'", cid); + g_signal_connect (connection, NM_SETTINGS_CONNECTION_REMOVED, + G_CALLBACK (connection_removed_cb), + self); if (nm_ifcfg_connection_get_unmanaged_spec (connection)) { const char *spec; |