From df796527a44ba9ca4e267afa26e242c6d2b9dec8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Klime=C5=A1?= Date: Mon, 11 Feb 2013 13:39:53 +0100 Subject: [PATCH] core: fix duplicating (not removing) active connections This is a regression introduced by reworked active connections tracking: 7258dd270f01d7956a2a61f4378a0a28b29db2d0 core: add the NM_ACTIVE_CONNECTION_STATE_DEACTIVATED state 59420add04de26ed9367feb966211a6446626803 core: track active connections directly in the manager Because nm-manager.c:active_connection_state_changed() postpones active connection removal to an idle handler (to be able to receive last property change notifications), we also need to ensure that NM_ACTIVE_CONNECTION_STATE_DEACTIVATED state is not changed again in the meantime in nm-activation-request.c:device_state_changed(). Reproducer: Just activate already active connection by clicking it in nm-applet or run 'nmcli con up id ' several times, and then check active connections with 'nmcli c s'. --- src/nm-activation-request.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/nm-activation-request.c b/src/nm-activation-request.c index 88504ce0dd..29fd7e2eea 100644 --- a/src/nm-activation-request.c +++ b/src/nm-activation-request.c @@ -298,6 +298,7 @@ static void device_state_changed (NMDevice *device, GParamSpec *pspec, NMActRequest *self) { NMActiveConnectionState ac_state = NM_ACTIVE_CONNECTION_STATE_UNKNOWN; + NMActiveConnectionState prev_ac_state = nm_active_connection_get_state (NM_ACTIVE_CONNECTION (self)); /* Set NMActiveConnection state based on the device's state */ switch (nm_device_get_state (device)) { @@ -329,7 +330,11 @@ device_state_changed (NMDevice *device, GParamSpec *pspec, NMActRequest *self) nm_active_connection_set_default6 (NM_ACTIVE_CONNECTION (self), FALSE); } - nm_active_connection_set_state (NM_ACTIVE_CONNECTION (self), ac_state); + /* Only set new state if we are not in DEACTIVATED. Those connections + * will be removed. See _active_connection_cleanup() in nm-manager.c + */ + if (prev_ac_state != NM_ACTIVE_CONNECTION_STATE_DEACTIVATED) + nm_active_connection_set_state (NM_ACTIVE_CONNECTION (self), ac_state); } /********************************************************************/