From db6e8b21e434b6644c6e69de02576172f07a5a6f Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Tue, 24 Jan 2017 13:57:05 +0100 Subject: [PATCH] active-connection: drop off the bus when the settings connection disappears The active connection has an immutable connection property, but is cleaned asynchronously by the manager after its settings connection is done. Fine, let's remove it from the bus first though, so that we don't hang there with a dangling object path. (cherry picked from commit f0e3dfdace25bf19c6a6b1f1cee4e384de64c433) --- src/nm-active-connection.c | 15 +++++++++++++++ src/settings/nm-settings.c | 6 ++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/nm-active-connection.c b/src/nm-active-connection.c index 17fb82e50..625c19e83 100644 --- a/src/nm-active-connection.c +++ b/src/nm-active-connection.c @@ -156,6 +156,20 @@ _settings_connection_updated (NMSettingsConnection *connection, * settings-connection. */ } +static void +_settings_connection_removed (NMSettingsConnection *connection, + gpointer user_data) +{ + NMActiveConnection *self = user_data; + + /* Our settings connection is about to drop off. The next active connection + * cleanup is going to tear us down (at least until we grow the capability to + * re-link; in that case we'd just clean the references to the old connection here). + * Let's remove ourselves from the bus so that we're not exposed with a dangling + * reference to the setting connection once it's gone. */ + nm_exported_object_unexport (NM_EXPORTED_OBJECT (self)); +} + static void _set_settings_connection (NMActiveConnection *self, NMSettingsConnection *connection) { @@ -170,6 +184,7 @@ _set_settings_connection (NMActiveConnection *self, NMSettingsConnection *connec if (connection) { priv->settings_connection = g_object_ref (connection); g_signal_connect (connection, NM_SETTINGS_CONNECTION_UPDATED_INTERNAL, (GCallback) _settings_connection_updated, self); + g_signal_connect (connection, NM_SETTINGS_CONNECTION_REMOVED, (GCallback) _settings_connection_removed, self); } } diff --git a/src/settings/nm-settings.c b/src/settings/nm-settings.c index 6a920d5cf..35790a126 100644 --- a/src/settings/nm-settings.c +++ b/src/settings/nm-settings.c @@ -1112,8 +1112,10 @@ claim_connection (NMSettings *self, NMSettingsConnection *connection) openconnect_migrate_hack (NM_CONNECTION (connection)); g_object_ref (self); - g_signal_connect (connection, NM_SETTINGS_CONNECTION_REMOVED, - G_CALLBACK (connection_removed), self); + /* This one unexports the connection, it needs to run late to give the active + * connection a chance to deal with its reference to this settings connection. */ + g_signal_connect_after (connection, NM_SETTINGS_CONNECTION_REMOVED, + G_CALLBACK (connection_removed), self); g_signal_connect (connection, NM_SETTINGS_CONNECTION_UPDATED_INTERNAL, G_CALLBACK (connection_updated), self); g_signal_connect (connection, "notify::" NM_SETTINGS_CONNECTION_VISIBLE,