[PATCH] Fix scan retry after a failure

Kalle Valo kalle.valo
Wed Oct 6 05:46:46 PDT 2010


With broadcom's "wl" driver the first scan always fails. (Apparently it also
doesn't send scan results ready signals, but let's forget it for now.) With
connman's five minute scan interval it meant that it would take five minutes
from boot until a wireless connection was established.

The reason is that currently wpasupplicant doesn't handle scan retries
and it goes directly to INACTIVE state:

14:23:09 wpa_supplicant[1046]: Scan timeout - try to get results
14:23:09 wpa_supplicant[1046]: Failed to get scan results
14:23:09 wpa_supplicant[1046]: Failed to get scan results - try scanning again
14:23:09 wpa_supplicant[1046]: State: SCANNING -> INACTIVE

Instead of going to INACTIVE set wpa_s->scan_req to make it explicit
that this is a requested scan and fix check in wpa_supplicant_req_new_scan().

This is based on Michael Terry's patch for wpasupplicant 0.6.x reported here:

http://w1.fi/bugz/show_bug.cgi?id=374
---
 wpa_supplicant/events.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c
index 85dcfb2..16373da 100644
--- a/wpa_supplicant/events.c
+++ b/wpa_supplicant/events.c
@@ -700,11 +700,12 @@ wpa_supplicant_pick_network(struct wpa_supplicant *wpa_s,
 static void wpa_supplicant_req_new_scan(struct wpa_supplicant *wpa_s,
 					int timeout_sec, int timeout_usec)
 {
-	if (!wpa_supplicant_enabled_networks(wpa_s->conf)) {
+	if (!wpa_supplicant_enabled_networks(wpa_s->conf) &&
+	    !wpa_s->scan_req) {
 		/*
-		 * No networks are enabled; short-circuit request so
-		 * we don't wait timeout seconds before transitioning
-		 * to INACTIVE state.
+		 * No networks are enabled nor explicit scan requests are
+		 * made; short-circuit request so we don't wait timeout
+		 * seconds before transitioning to INACTIVE state.
 		 */
 		wpa_supplicant_set_state(wpa_s, WPA_INACTIVE);
 		return;
@@ -893,6 +894,7 @@ static void wpa_supplicant_event_scan_results(struct wpa_supplicant *wpa_s,
 			return;
 		wpa_printf(MSG_DEBUG, "Failed to get scan results - try "
 			   "scanning again");
+		wpa_s->scan_req = 2;
 		wpa_supplicant_req_new_scan(wpa_s, 1, 0);
 		return;
 	}




More information about the Hostap mailing list