From 592dc6f2446c2e04fe995584965c3c9f28da2607 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Mon, 8 Oct 2007 18:07:36 +0000 Subject: [PATCH] 2007-10-08 Dan Williams Reimplement the invalid connection list. Don't try to re-activate a connection that just failed or was canceled. * src/nm-device.c - (connection_secrets_failed_cb): fail device activation, don't just deactivate the device. Listeners have to know about the failure. * src/NetworkManagerPolicy.c - (nm_policy_auto_get_best_device): exclude invalid connections from the connection list given to a device's get_best_connection() method - (device_state_changed): tag failed connections as invalid; clear the tag from successful connections git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2957 4912f4e0-d625-0410-9fb7-b9a5a253dbdc --- ChangeLog | 16 ++++++++++++++ src/NetworkManagerPolicy.c | 43 +++++++++++++++++++++++++++++++++++++- src/nm-device.c | 2 +- 3 files changed, 59 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 96137ae04d..e2b58b57e9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2007-10-08 Dan Williams + + Reimplement the invalid connection list. Don't try to re-activate a + connection that just failed or was canceled. + + * src/nm-device.c + - (connection_secrets_failed_cb): fail device activation, don't just + deactivate the device. Listeners have to know about the failure. + + * src/NetworkManagerPolicy.c + - (nm_policy_auto_get_best_device): exclude invalid connections from + the connection list given to a device's get_best_connection() + method + - (device_state_changed): tag failed connections as invalid; clear the + tag from successful connections + 2007-10-08 Dan Williams Fix problems with interrupted activation. Previously, choosing an AP diff --git a/src/NetworkManagerPolicy.c b/src/NetworkManagerPolicy.c index c368934df5..c7561cbc3c 100644 --- a/src/NetworkManagerPolicy.c +++ b/src/NetworkManagerPolicy.c @@ -45,6 +45,8 @@ struct NMPolicy { guint device_state_changed_idle_id; }; +#define INVALID_TAG "invalid" + static void schedule_change_check (NMPolicy *policy); /* NMPolicy is supposed to be one of the highest classes of the @@ -106,6 +108,20 @@ nm_policy_auto_get_best_device (NMPolicy *policy, connections = nm_manager_get_connections (policy->manager, NM_CONNECTION_TYPE_SYSTEM); connections = g_slist_concat (connections, nm_manager_get_connections (policy->manager, NM_CONNECTION_TYPE_USER)); + /* Remove connections that are in the invalid list. */ + elt = connections; + while (elt) { + NMConnection *iter_connection = NM_CONNECTION (elt->data); + GSList *next = g_slist_next (elt); + + if (g_object_get_data (G_OBJECT (iter_connection), INVALID_TAG)) { + connections = g_slist_remove_link (connections, elt); + g_object_unref (iter_connection); + g_slist_free (elt); + } + elt = next; + } + for (elt = nm_manager_get_devices (policy->manager); elt; elt = elt->next) { NMConnection *tmp_con = NULL; char *tmp_obj = NULL; @@ -387,13 +403,38 @@ schedule_change_check (NMPolicy *policy) device_change_check_done); } +static NMConnection * +get_device_connection (NMDevice *device) +{ + NMActRequest *req; + NMConnection *connection; + + req = nm_device_get_act_request (device); + if (!req) + return NULL; + + return nm_act_request_get_connection (req); +} + static void device_state_changed (NMDevice *device, NMDeviceState state, gpointer user_data) { NMPolicy *policy = (NMPolicy *) user_data; + NMConnection *connection = get_device_connection (device); - if (state == NM_DEVICE_STATE_FAILED || state == NM_DEVICE_STATE_CANCELLED) + if ((state == NM_DEVICE_STATE_FAILED) || (state == NM_DEVICE_STATE_CANCELLED)) { schedule_change_check (policy); + + /* Mark the connection invalid so it doesn't get automatically chosen */ + if (connection) { + g_object_set_data (G_OBJECT (connection), INVALID_TAG, GUINT_TO_POINTER (TRUE)); + nm_info ("Marking connection '%s' invalid.", get_connection_name (connection)); + } + } else if (state == NM_DEVICE_STATE_ACTIVATED) { + /* Clear the invalid tag on the connection */ + if (connection) + g_object_set_data (G_OBJECT (connection), INVALID_TAG, NULL); + } } static void diff --git a/src/nm-device.c b/src/nm-device.c index fcaabd1add..34225a596e 100644 --- a/src/nm-device.c +++ b/src/nm-device.c @@ -1110,7 +1110,7 @@ connection_secrets_failed_cb (NMActRequest *req, { NMDevice *self = NM_DEVICE (user_data); - nm_device_interface_deactivate (NM_DEVICE_INTERFACE (self)); + nm_device_state_changed (self, NM_DEVICE_STATE_FAILED); } static gboolean