[PATCH] fix supplicant state handling for AP out of range case



Currently NM will never mark a wireless connection as "down" when the
AP is out of range or shut down.
It starts a timeout of 15 sec to wait for the supplicant to re
authenticate. But if the supplicant is scanning it will keep
restarting the timeout (and keep the connection "up" even thought
there is no link).
The attached patch fixes this by increasing the timeout to 30 sec in
the "SCANNING" case.

----------------------

Fix supplicant state handling for AP out of range case.

Signed-off-by: Adel Gadllah <adel gadllah gmail com>

diff -upNr NetworkManager-0.7.0.orign/src/nm-device-wifi.c
NetworkManager-0.7.0/src/nm-device-wifi.c
--- NetworkManager-0.7.0.orign/src/nm-device-wifi.c	2008-06-10
18:06:36.000000000 +0200
+++ NetworkManager-0.7.0/src/nm-device-wifi.c	2008-06-20
17:32:54.000000000 +0200
@@ -1951,10 +1951,6 @@ link_timeout_cb (gpointer user_data)

 	g_assert (dev);

-	/* If currently scanning and disconnected still, check again later. */
-	if (priv->scanning)
-		return TRUE;
-
 	priv->link_timeout_id = 0;

 	req = nm_device_get_act_request (dev);
@@ -2130,6 +2126,12 @@ supplicant_iface_connection_state_cb_han
 	nm_info ("(%s): supplicant connection state change: %d -> %d",
 	         nm_device_get_iface (dev), old_state, new_state);

+	if (new_state == NM_SUPPLICANT_INTERFACE_CON_STATE_SCANNING) {
+		self->priv->scanning = TRUE;
+	} else {
+		self->priv->scanning = FALSE;
+	}
+
 	if (new_state == NM_SUPPLICANT_INTERFACE_CON_STATE_COMPLETED) {
 		remove_supplicant_interface_connection_error_handler (self);
 		remove_supplicant_timeouts (self);
@@ -2149,18 +2151,15 @@ supplicant_iface_connection_state_cb_han
 		}
 	} else if (new_state == NM_SUPPLICANT_INTERFACE_CON_STATE_DISCONNECTED) {
 		if (nm_device_get_state (dev) == NM_DEVICE_STATE_ACTIVATED ||
nm_device_is_activating (dev)) {
-			/* Start the link timeout so we allow some time for reauthentication */
+			/* Start the link timeout so we allow some time for reauthentication,
+			 * use a longer timeout if we are scanning
+			 */
 			if (!self->priv->link_timeout_id)
-				self->priv->link_timeout_id = g_timeout_add (15000, link_timeout_cb, self);
+				self->priv->link_timeout_id = g_timeout_add
((self->priv->scanning) ? 30000:15000,
+				 link_timeout_cb, self);
 		}
 	}

-	if (new_state == NM_SUPPLICANT_INTERFACE_CON_STATE_SCANNING) {
-		self->priv->scanning = TRUE;
-	} else {
-		self->priv->scanning = FALSE;
-	}
-
 out:
 	g_slice_free (struct state_cb_data, cb_data);
 	return FALSE;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]