]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Update scan interval gracefully
authorPontus Fuchs <pontus.fuchs@gmail.com>
Sun, 3 Feb 2013 16:14:05 +0000 (18:14 +0200)
committerJouni Malinen <j@w1.fi>
Sun, 3 Feb 2013 16:14:05 +0000 (18:14 +0200)
When the scan interval is changed the new interval is effective
after the old interval timer fires off one last time. This can cause
an unacceptable long delay when updating the interval.

Change this behaviour to use MIN(left of old interval, new interval)
for the scan interval following the interval change.

Signed-hostap: Pontus Fuchs <pontus.fuchs@gmail.com>

wpa_supplicant/scan.c
wpa_supplicant/scan.h
wpa_supplicant/wpa_supplicant.c

index d2b671a9a503af6936710e51c5f77e1cdff7d27a..25a9ef821ef8da9aabde51bcd03a5719a892ce73 100644 (file)
@@ -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
index 5096287af6a3863dbc7ded07b5e1822e00ecb81d..7a9b232d0c957d7127ae4a2a6551b889a63ee829 100644 (file)
@@ -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 */
index 64f5c1bded1d98772c042dec735899b327b79134..21bd73a73c727ba82d3b38763d1669dc2860d6e6 100644 (file)
@@ -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;
 }