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.
This commit is contained in:
Lubomir Rintel
2017-01-24 13:57:05 +01:00
parent 9fff9f501a
commit f0e3dfdace
2 changed files with 19 additions and 2 deletions

View File

@@ -156,6 +156,20 @@ _settings_connection_updated (NMSettingsConnection *connection,
* settings-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 static void
_set_settings_connection (NMActiveConnection *self, NMSettingsConnection *connection) _set_settings_connection (NMActiveConnection *self, NMSettingsConnection *connection)
{ {
@@ -170,6 +184,7 @@ _set_settings_connection (NMActiveConnection *self, NMSettingsConnection *connec
if (connection) { if (connection) {
priv->settings_connection = g_object_ref (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_UPDATED_INTERNAL, (GCallback) _settings_connection_updated, self);
g_signal_connect (connection, NM_SETTINGS_CONNECTION_REMOVED, (GCallback) _settings_connection_removed, self);
} }
} }

View File

@@ -1112,7 +1112,9 @@ claim_connection (NMSettings *self, NMSettingsConnection *connection)
openconnect_migrate_hack (NM_CONNECTION (connection)); openconnect_migrate_hack (NM_CONNECTION (connection));
g_object_ref (self); g_object_ref (self);
g_signal_connect (connection, NM_SETTINGS_CONNECTION_REMOVED, /* 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_CALLBACK (connection_removed), self);
g_signal_connect (connection, NM_SETTINGS_CONNECTION_UPDATED_INTERNAL, g_signal_connect (connection, NM_SETTINGS_CONNECTION_UPDATED_INTERNAL,
G_CALLBACK (connection_updated), self); G_CALLBACK (connection_updated), self);