summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2013-08-08 15:57:57 -0500
committerDan Williams <dcbw@redhat.com>2013-08-09 00:54:58 -0500
commite16e8ab7fba19203536ed5f9518c31265c8775f0 (patch)
tree7b34c8d1cb0898052b298ad7edd72063c5dda63f
parentb5170903c0c5bdb5fb3820822aa0d57b3e11cf8f (diff)
downloadNetworkManager-e16e8ab7fba19203536ed5f9518c31265c8775f0.tar.gz
policy: prevent double-deactivation of an NMActiveConnection after it's removed
When a connection is removed from NMSettings, it gets deactivated. That was happening once in response to the now-removed connection's visibility changing to invisible to everyone, and a second time in response to the actual removal signal. Unfortunately the second time the NMActiveConnection is already cleaned up and in the DEACTIVATED state, and has no priv->device, which causes great hilarity when nm_device_set_state() is called with NULL. _deactivate_if_active() should only try to deactivate NMActiveConnections that actually are active.
-rw-r--r--src/nm-policy.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/nm-policy.c b/src/nm-policy.c
index ff6f71a2e6..525fbc7741 100644
--- a/src/nm-policy.c
+++ b/src/nm-policy.c
@@ -1811,9 +1811,11 @@ _deactivate_if_active (NMManager *manager, NMConnection *connection)
active = nm_manager_get_active_connections (manager);
for (iter = active; iter; iter = g_slist_next (iter)) {
NMActiveConnection *ac = iter->data;
+ NMActiveConnectionState state = nm_active_connection_get_state (ac);
GError *error = NULL;
- if (nm_active_connection_get_connection (ac) == connection) {
+ if (nm_active_connection_get_connection (ac) == connection &&
+ (state <= NM_ACTIVE_CONNECTION_STATE_ACTIVATED)) {
if (!nm_manager_deactivate_connection (manager,
nm_active_connection_get_path (ac),
NM_DEVICE_STATE_REASON_CONNECTION_REMOVED,