P2P: Abort ongoing scan when p2p_find is stopped
authorBen Rosenfeld <ben.rosenfeld@intel.com>
Mon, 29 Feb 2016 12:30:04 +0000 (14:30 +0200)
committerJouni Malinen <j@w1.fi>
Thu, 3 Mar 2016 15:10:26 +0000 (17:10 +0200)
When p2p_find is stopped, send request to the driver
in order to cancel an ongoing scan if there is one.

Signed-off-by: Ben Rosenfeld <ben.rosenfeld@intel.com>
wpa_supplicant/p2p_supplicant.c
wpa_supplicant/scan.c

index 3e31f41..cf2653d 100644 (file)
@@ -2389,6 +2389,10 @@ static void wpas_dev_lost(void *ctx, const u8 *dev_addr)
 static void wpas_find_stopped(void *ctx)
 {
        struct wpa_supplicant *wpa_s = ctx;
+
+       if (wpa_s->p2p_scan_work && wpas_abort_ongoing_scan(wpa_s) < 0)
+               wpa_printf(MSG_DEBUG, "P2P: Abort ongoing scan failed");
+
        wpa_msg_global(wpa_s, MSG_INFO, P2P_EVENT_FIND_STOPPED);
        wpas_notify_p2p_find_stopped(wpa_s);
 }
index 2ce3929..3463dd9 100644 (file)
@@ -2544,7 +2544,13 @@ int wpas_mac_addr_rand_scan_set(struct wpa_supplicant *wpa_s,
 
 int wpas_abort_ongoing_scan(struct wpa_supplicant *wpa_s)
 {
-       if (wpa_s->scan_work && wpa_s->own_scan_running) {
+       int scan_work = !!wpa_s->scan_work;
+
+#ifdef CONFIG_P2P
+       scan_work |= !!wpa_s->p2p_scan_work;
+#endif /* CONFIG_P2P */
+
+       if (scan_work && wpa_s->own_scan_running) {
                wpa_dbg(wpa_s, MSG_DEBUG, "Abort an ongoing scan");
                return wpa_drv_abort_scan(wpa_s);
        }