From a805731086c3c99fde971e6a62a3fd2eebaf2b8c Mon Sep 17 00:00:00 2001 From: Ben Rosenfeld Date: Mon, 29 Feb 2016 14:30:04 +0200 Subject: [PATCH] P2P: Abort ongoing scan when p2p_find is stopped 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 --- wpa_supplicant/p2p_supplicant.c | 4 ++++ wpa_supplicant/scan.c | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c index 3e31f41b5..cf2653de9 100644 --- a/wpa_supplicant/p2p_supplicant.c +++ b/wpa_supplicant/p2p_supplicant.c @@ -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); } diff --git a/wpa_supplicant/scan.c b/wpa_supplicant/scan.c index 2ce3929ed..3463dd926 100644 --- a/wpa_supplicant/scan.c +++ b/wpa_supplicant/scan.c @@ -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); }