core: fix duplicating (not removing) active connections

This is a regression introduced by reworked active connections tracking:
7258dd270f core: add the NM_ACTIVE_CONNECTION_STATE_DEACTIVATED state
59420add04 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 <connnection name>' several times, and then check
active connections with 'nmcli c s'.
This commit is contained in:
Jiří Klimeš
2013-02-11 13:39:53 +01:00
parent 17aff29082
commit df796527a4

View File

@@ -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,6 +330,10 @@ device_state_changed (NMDevice *device, GParamSpec *pspec, NMActRequest *self)
nm_active_connection_set_default6 (NM_ACTIVE_CONNECTION (self), FALSE);
}
/* 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);
}