Do not continually reschedule specific scans to help finding hidden SSIDs
[libeap.git] / wpa_supplicant / scan.c
index b046d90..c2549e2 100644 (file)
@@ -172,6 +172,28 @@ static void wpa_supplicant_scan(void *eloop_ctx, void *timeout_ctx)
  */
 void wpa_supplicant_req_scan(struct wpa_supplicant *wpa_s, int sec, int usec)
 {
+       /* If there's at least one network that should be specifically scanned
+        * then don't cancel the scan and reschedule.  Some drivers do
+        * background scanning which generates frequent scan results, and that
+        * causes the specific SSID scan to get continually pushed back and
+        * never happen, which causes hidden APs to never get probe-scanned.
+        */
+       if (eloop_is_timeout_registered(wpa_supplicant_scan, wpa_s, NULL) &&
+           wpa_s->conf->ap_scan == 1) {
+               struct wpa_ssid *ssid = wpa_s->conf->ssid;
+
+               while (ssid) {
+                       if (!ssid->disabled && ssid->scan_ssid)
+                               break;
+                       ssid = ssid->next;
+               }
+               if (ssid) {
+                       wpa_msg(wpa_s, MSG_DEBUG, "Not rescheduling scan to "
+                               "ensure that specific SSID scans occur");
+                       return;
+               }
+       }
+
        wpa_msg(wpa_s, MSG_DEBUG, "Setting scan request: %d sec %d usec",
                sec, usec);
        eloop_cancel_timeout(wpa_supplicant_scan, wpa_s, NULL);