diff --git a/src/p2p/p2p.c b/src/p2p/p2p.c index 6b92a6d23..74b7b52ae 100644 --- a/src/p2p/p2p.c +++ b/src/p2p/p2p.c @@ -3510,12 +3510,17 @@ int p2p_scan_res_handler(struct p2p_data *p2p, const u8 *bssid, int freq, } -void p2p_scan_res_handled(struct p2p_data *p2p) +void p2p_scan_res_handled(struct p2p_data *p2p, unsigned int delay) { if (!p2p->p2p_scan_running) { p2p_dbg(p2p, "p2p_scan was not running, but scan results received"); } p2p->p2p_scan_running = 0; + + /* Use this delay only when p2p_find doesn't set it */ + if (!p2p->search_delay) + p2p->search_delay = delay; + eloop_cancel_timeout(p2p_scan_timeout, p2p, NULL); if (p2p_run_after_scan(p2p)) diff --git a/src/p2p/p2p.h b/src/p2p/p2p.h index ed8beab19..762bd40be 100644 --- a/src/p2p/p2p.h +++ b/src/p2p/p2p.h @@ -1625,6 +1625,7 @@ int p2p_scan_res_handler(struct p2p_data *p2p, const u8 *bssid, int freq, /** * p2p_scan_res_handled - Indicate end of scan results * @p2p: P2P module context from p2p_init() + * @delay: Search delay for next scan in ms * * This function is called to indicate that all P2P scan results from a scan * have been reported with zero or more calls to p2p_scan_res_handler(). This @@ -1632,7 +1633,7 @@ int p2p_scan_res_handler(struct p2p_data *p2p, const u8 *bssid, int freq, * struct p2p_config::p2p_scan() call if none of the p2p_scan_res_handler() * calls stopped iteration. */ -void p2p_scan_res_handled(struct p2p_data *p2p); +void p2p_scan_res_handled(struct p2p_data *p2p, unsigned int delay); enum p2p_send_action_result { P2P_SEND_ACTION_SUCCESS /* Frame was send and acknowledged */, diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c index 8c8a834da..7d6e2dac8 100644 --- a/wpa_supplicant/p2p_supplicant.c +++ b/wpa_supplicant/p2p_supplicant.c @@ -242,6 +242,22 @@ static void wpas_p2p_set_own_freq_preference(struct wpa_supplicant *wpa_s, } +static void wpas_p2p_scan_res_handled(struct wpa_supplicant *wpa_s) +{ + unsigned int delay = wpas_p2p_search_delay(wpa_s); + + /* In case of concurrent P2P and external scans, delay P2P search. */ + if (wpa_s->radio->external_scan_running) { + delay = wpa_s->conf->p2p_search_delay; + wpa_printf(MSG_DEBUG, + "P2P: Delay next P2P search by %d ms to let externally triggered scan complete", + delay); + } + + p2p_scan_res_handled(wpa_s->global->p2p, delay); +} + + static void wpas_p2p_scan_res_handler(struct wpa_supplicant *wpa_s, struct wpa_scan_results *scan_res) { @@ -287,7 +303,7 @@ static void wpas_p2p_scan_res_handler(struct wpa_supplicant *wpa_s, break; } - p2p_scan_res_handled(wpa_s->global->p2p); + wpas_p2p_scan_res_handled(wpa_s); } @@ -305,7 +321,7 @@ static void wpas_p2p_scan_res_fail_handler(struct wpa_supplicant *wpa_s) wpa_dbg(wpa_s, MSG_DEBUG, "P2P: Failed to get scan results - try to continue"); - p2p_scan_res_handled(wpa_s->global->p2p); + wpas_p2p_scan_res_handled(wpa_s); } @@ -7089,7 +7105,7 @@ static void wpas_p2p_scan_res_ignore_search(struct wpa_supplicant *wpa_s, * Indicate that results have been processed so that the P2P module can * continue pending tasks. */ - p2p_scan_res_handled(wpa_s->global->p2p); + wpas_p2p_scan_res_handled(wpa_s); }