From d93dfbd588eb3c16f4ed1b7af825c9c1c9bf7f6d Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sat, 4 Feb 2012 12:28:16 +0200 Subject: [PATCH] Delay scan request on select_network if disconnecting The disconnection command results in disassociation and deauthentication events which were previously processed during the scan in case of select_network command being used while associated with another network. While this works in most cases, it can result in confusing event messages in ctrl_iface and debug log. Avoid this by using a short delay between the disconnection and scan request to allow the disconnection events to be processed prior to starting the new scan. Signed-hostap: Jouni Malinen intended-for: hostap-1 --- wpa_supplicant/wpa_supplicant.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c index 4d3e30735..9acc89a75 100644 --- a/wpa_supplicant/wpa_supplicant.c +++ b/wpa_supplicant/wpa_supplicant.c @@ -1,6 +1,6 @@ /* * WPA Supplicant - * Copyright (c) 2003-2011, Jouni Malinen + * Copyright (c) 2003-2012, Jouni Malinen * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as @@ -1667,10 +1667,13 @@ void wpa_supplicant_select_network(struct wpa_supplicant *wpa_s, { struct wpa_ssid *other_ssid; + int disconnected = 0; - if (ssid && ssid != wpa_s->current_ssid && wpa_s->current_ssid) + if (ssid && ssid != wpa_s->current_ssid && wpa_s->current_ssid) { wpa_supplicant_disassociate( wpa_s, WLAN_REASON_DEAUTH_LEAVING); + disconnected = 1; + } /* * Mark all other networks disabled or mark all networks enabled if no @@ -1698,7 +1701,7 @@ void wpa_supplicant_select_network(struct wpa_supplicant *wpa_s, wpa_s->connect_without_scan = NULL; wpa_s->disconnected = 0; wpa_s->reassociate = 1; - wpa_supplicant_req_scan(wpa_s, 0, 0); + wpa_supplicant_req_scan(wpa_s, 0, disconnected ? 100000 : 0); if (ssid) wpas_notify_network_selected(wpa_s, ssid);