Do not inform other virtual interfaces of scan results in all cases
[mech_eap.git] / wpa_supplicant / events.c
index 6dd5787..17db408 100644 (file)
@@ -1030,7 +1030,7 @@ static int wpa_supplicant_need_to_roam(struct wpa_supplicant *wpa_s,
 }
 
 
-/* Return < 0 if no scan results could be fetched or if scan results should not
+/* Return != 0 if no scan results could be fetched or if scan results should not
  * be shared with other virtual interfaces. */
 static int _wpa_supplicant_event_scan_results(struct wpa_supplicant *wpa_s,
                                              union wpa_event_data *data)
@@ -1049,12 +1049,15 @@ static int _wpa_supplicant_event_scan_results(struct wpa_supplicant *wpa_s,
        wpa_supplicant_notify_scanning(wpa_s, 0);
 
 #ifdef CONFIG_P2P
-       if (wpa_s->p2p_cb_on_scan_complete && !wpa_s->global->p2p_disabled &&
+       if (wpa_s->global->p2p_cb_on_scan_complete &&
+           !wpa_s->global->p2p_disabled &&
            wpa_s->global->p2p != NULL && !wpa_s->sta_scan_pending) {
-               wpa_s->p2p_cb_on_scan_complete = 0;
+               wpa_s->global->p2p_cb_on_scan_complete = 0;
                if (p2p_other_scan_completed(wpa_s->global->p2p) == 1) {
                        wpa_dbg(wpa_s, MSG_DEBUG, "P2P: Pending P2P operation "
                                "stopped scan processing");
+                       wpa_s->sta_scan_pending = 1;
+                       wpa_supplicant_req_scan(wpa_s, 5, 0);
                        return -1;
                }
        }
@@ -1172,6 +1175,11 @@ int wpas_select_network_from_last_scan(struct wpa_supplicant *wpa_s)
                        return -1;
                }
                wpa_supplicant_rsn_preauth_scan_results(wpa_s);
+               /*
+                * Do not notify other virtual radios of scan results since we do not
+                * want them to start other associations at the same time.
+                */
+               return 1;
        } else {
                wpa_dbg(wpa_s, MSG_DEBUG, "No suitable network found");
                ssid = wpa_supplicant_pick_new_network(wpa_s);
@@ -1208,7 +1216,7 @@ int wpas_select_network_from_last_scan(struct wpa_supplicant *wpa_s)
                                wpa_s->network_select = 1;
                                wpa_s->auto_network_select = 1;
                                interworking_start_fetch_anqp(wpa_s);
-                               return 0;
+                               return 1;
                        }
 #endif /* CONFIG_INTERWORKING */
                        if (wpa_supplicant_req_sched_scan(wpa_s))
@@ -1226,11 +1234,13 @@ static void wpa_supplicant_event_scan_results(struct wpa_supplicant *wpa_s,
        const char *rn, *rn2;
        struct wpa_supplicant *ifs;
 
-       if (_wpa_supplicant_event_scan_results(wpa_s, data) < 0) {
+       if (_wpa_supplicant_event_scan_results(wpa_s, data) != 0) {
                /*
                 * If no scan results could be fetched, then no need to
                 * notify those interfaces that did not actually request
-                * this scan.
+                * this scan. Similarly, if scan results started a new operation on this
+                * interface, do not notify other interfaces to avoid concurrent
+                * operations during a connection attempt.
                 */
                return;
        }
@@ -2412,11 +2422,11 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
        case EVENT_SCAN_RESULTS:
                wpa_supplicant_event_scan_results(wpa_s, data);
 #ifdef CONFIG_P2P
-       if (wpa_s->p2p_cb_on_scan_complete && !wpa_s->global->p2p_disabled &&
+       if (wpa_s->global->p2p_cb_on_scan_complete && !wpa_s->global->p2p_disabled &&
            wpa_s->global->p2p != NULL &&
            wpa_s->wpa_state != WPA_AUTHENTICATING &&
            wpa_s->wpa_state != WPA_ASSOCIATING) {
-               wpa_s->p2p_cb_on_scan_complete = 0;
+               wpa_s->global->p2p_cb_on_scan_complete = 0;
                if (p2p_other_scan_completed(wpa_s->global->p2p) == 1) {
                        wpa_dbg(wpa_s, MSG_DEBUG, "P2P: Pending P2P operation "
                                "continued after scan result processing");