diff --git a/wpa_supplicant/scan.c b/wpa_supplicant/scan.c index d2b671a9a..25a9ef821 100644 --- a/wpa_supplicant/scan.c +++ b/wpa_supplicant/scan.c @@ -816,6 +816,27 @@ scan: } +void wpa_supplicant_update_scan_int(struct wpa_supplicant *wpa_s, int sec) +{ + struct os_time remaining, new_int; + int cancelled; + + cancelled = eloop_cancel_timeout_one(wpa_supplicant_scan, wpa_s, NULL, + &remaining); + + new_int.sec = sec; + new_int.usec = 0; + if (cancelled && os_time_before(&remaining, &new_int)) { + new_int.sec = remaining.sec; + new_int.usec = remaining.usec; + } + + eloop_register_timeout(new_int.sec, new_int.usec, wpa_supplicant_scan, + wpa_s, NULL); + wpa_s->scan_interval = sec; +} + + /** * wpa_supplicant_req_scan - Schedule a scan for neighboring access points * @wpa_s: Pointer to wpa_supplicant data diff --git a/wpa_supplicant/scan.h b/wpa_supplicant/scan.h index 5096287af..7a9b232d0 100644 --- a/wpa_supplicant/scan.h +++ b/wpa_supplicant/scan.h @@ -32,5 +32,6 @@ struct wpabuf * wpa_scan_get_vendor_ie_multi(const struct wpa_scan_res *res, u32 vendor_type); int wpa_supplicant_filter_bssid_match(struct wpa_supplicant *wpa_s, const u8 *bssid); +void wpa_supplicant_update_scan_int(struct wpa_supplicant *wpa_s, int sec); #endif /* SCAN_H */ diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c index 64f5c1bde..21bd73a73 100644 --- a/wpa_supplicant/wpa_supplicant.c +++ b/wpa_supplicant/wpa_supplicant.c @@ -1980,7 +1980,7 @@ int wpa_supplicant_set_scan_interval(struct wpa_supplicant *wpa_s, } wpa_msg(wpa_s, MSG_DEBUG, "Setting scan interval: %d sec", scan_interval); - wpa_s->scan_interval = scan_interval; + wpa_supplicant_update_scan_int(wpa_s, scan_interval); return 0; }