diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c index fa8f5e1c0..d9ecbefc0 100644 --- a/wpa_supplicant/events.c +++ b/wpa_supplicant/events.c @@ -2091,9 +2091,18 @@ static int _wpa_supplicant_event_scan_results(struct wpa_supplicant *wpa_s, return -1; if (data && data->scan_info.external_scan) return -1; - wpa_dbg(wpa_s, MSG_DEBUG, "Failed to get scan results - try " - "scanning again"); - wpa_supplicant_req_new_scan(wpa_s, 1, 0); + if (wpa_s->scan_res_fail_handler) { + void (*handler)(struct wpa_supplicant *wpa_s); + + handler = wpa_s->scan_res_fail_handler; + wpa_s->scan_res_fail_handler = NULL; + handler(wpa_s); + } else { + wpa_dbg(wpa_s, MSG_DEBUG, + "Failed to get scan results - try scanning again"); + wpa_supplicant_req_new_scan(wpa_s, 1, 0); + } + ret = -1; goto scan_work_done; } diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c index 867874dd9..8c8a834da 100644 --- a/wpa_supplicant/p2p_supplicant.c +++ b/wpa_supplicant/p2p_supplicant.c @@ -291,6 +291,24 @@ static void wpas_p2p_scan_res_handler(struct wpa_supplicant *wpa_s, } +static void wpas_p2p_scan_res_fail_handler(struct wpa_supplicant *wpa_s) +{ + if (wpa_s->p2p_scan_work) { + struct wpa_radio_work *work = wpa_s->p2p_scan_work; + + wpa_s->p2p_scan_work = NULL; + radio_work_done(work); + } + + if (wpa_s->global->p2p_disabled || !wpa_s->global->p2p) + return; + + wpa_dbg(wpa_s, MSG_DEBUG, + "P2P: Failed to get scan results - try to continue"); + p2p_scan_res_handled(wpa_s->global->p2p); +} + + static void wpas_p2p_trigger_scan_cb(struct wpa_radio_work *work, int deinit) { struct wpa_supplicant *wpa_s = work->wpa_s; @@ -335,6 +353,7 @@ static void wpas_p2p_trigger_scan_cb(struct wpa_radio_work *work, int deinit) p2p_notify_scan_trigger_status(wpa_s->global->p2p, ret); os_get_reltime(&wpa_s->scan_trigger_time); wpa_s->scan_res_handler = wpas_p2p_scan_res_handler; + wpa_s->scan_res_fail_handler = wpas_p2p_scan_res_fail_handler; wpa_s->own_scan_requested = 1; wpa_s->clear_driver_scan_cache = 0; wpa_s->p2p_scan_work = work; diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h index 568e383b1..51fa00702 100644 --- a/wpa_supplicant/wpa_supplicant_i.h +++ b/wpa_supplicant/wpa_supplicant_i.h @@ -619,6 +619,7 @@ struct wpa_supplicant { void (*scan_res_handler)(struct wpa_supplicant *wpa_s, struct wpa_scan_results *scan_res); + void (*scan_res_fail_handler)(struct wpa_supplicant *wpa_s); struct dl_list bss; /* struct wpa_bss::list */ struct dl_list bss_id; /* struct wpa_bss::list_id */ size_t num_bss;