core: reset auto retries counter when cable is replugged

When re-plugging we may be in a different network. So we should try the
compatible connections again.

Based on a patch from Mikhail Efremov.
This commit is contained in:
Jiří Klimeš
2011-05-30 12:07:41 +01:00
parent 6780818974
commit 9aa7efcf28

View File

@@ -817,13 +817,17 @@ hostname_changed (NMManager *manager, GParamSpec *pspec, gpointer user_data)
} }
static void static void
reset_retries_all (NMSettings *settings) reset_retries_all (NMSettings *settings, NMDevice *device)
{ {
GSList *connections, *iter; GSList *connections, *iter;
GError *error = NULL;
connections = nm_settings_get_connections (settings); connections = nm_settings_get_connections (settings);
for (iter = connections; iter; iter = g_slist_next (iter)) for (iter = connections; iter; iter = g_slist_next (iter)) {
set_connection_auto_retries (NM_CONNECTION (iter->data), RETRIES_DEFAULT); if (!device || nm_device_interface_check_connection_compatible (NM_DEVICE_INTERFACE (device), iter->data, &error))
set_connection_auto_retries (NM_CONNECTION (iter->data), RETRIES_DEFAULT);
g_clear_error (&error);
}
g_slist_free (connections); g_slist_free (connections);
} }
@@ -838,7 +842,7 @@ sleeping_changed (NMManager *manager, GParamSpec *pspec, gpointer user_data)
/* Reset retries on all connections so they'll checked on wakeup */ /* Reset retries on all connections so they'll checked on wakeup */
if (sleeping || !enabled) if (sleeping || !enabled)
reset_retries_all (policy->settings); reset_retries_all (policy->settings, NULL);
} }
static void static void
@@ -932,6 +936,11 @@ device_state_changed (NMDevice *device,
update_routing_and_dns (policy, FALSE); update_routing_and_dns (policy, FALSE);
break; break;
case NM_DEVICE_STATE_DISCONNECTED: case NM_DEVICE_STATE_DISCONNECTED:
/* Clear INVALID_TAG when carrier on. If cable was unplugged
* and plugged again, we should try to reconnect */
if (reason == NM_DEVICE_STATE_REASON_CARRIER && old_state == NM_DEVICE_STATE_UNAVAILABLE)
reset_retries_all (policy->settings, device);
/* Device is now available for auto-activation */ /* Device is now available for auto-activation */
update_routing_and_dns (policy, FALSE); update_routing_and_dns (policy, FALSE);
schedule_activate_check (policy, device, 0); schedule_activate_check (policy, device, 0);
@@ -1058,7 +1067,7 @@ connections_loaded (NMSettings *settings, gpointer user_data)
// that by calling reset_retries_all() in nm_policy_new() // that by calling reset_retries_all() in nm_policy_new()
/* Initialize connections' auto-retries */ /* Initialize connections' auto-retries */
reset_retries_all (settings); reset_retries_all (settings, NULL);
schedule_activate_all ((NMPolicy *) user_data); schedule_activate_all ((NMPolicy *) user_data);
} }
@@ -1188,7 +1197,7 @@ nm_policy_new (NMManager *manager,
connection_visibility_changed); connection_visibility_changed);
/* Initialize connections' auto-retries */ /* Initialize connections' auto-retries */
reset_retries_all (policy->settings); reset_retries_all (policy->settings, NULL);
initialized = TRUE; initialized = TRUE;
return policy; return policy;