2007-10-08 Dan Williams <dcbw@redhat.com>

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
This commit is contained in:
Dan Williams 2007-10-08 18:07:36 +00:00
parent 8bb7cdee1a
commit 592dc6f244
3 changed files with 59 additions and 2 deletions

View file

@ -1,3 +1,19 @@
2007-10-08 Dan Williams <dcbw@redhat.com>
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 <dcbw@redhat.com>
Fix problems with interrupted activation. Previously, choosing an AP

View file

@ -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

View file

@ -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