wifi: Check device is not already scanning before a new scan.
authorTomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Fri, 25 May 2012 08:17:41 +0000 (11:17 +0300)
committerPatrik Flykt <patrik.flykt@linux.intel.com>
Fri, 25 May 2012 11:54:37 +0000 (14:54 +0300)
gsupplicant's interface scanning value is slow to be updated since it's wpa_s event
which updates it, thus leading to a time gap where it is possible to request another scan.
It will therefore reference once again device, which will lead to too many references hold
by wifi plugin

plugins/wifi.c

index ee11413..09d7ab4 100644 (file)
@@ -405,6 +405,9 @@ static int throw_wifi_scan(struct connman_device *device,
        if (wifi->tethering == TRUE)
                return 0;
 
+       if (connman_device_get_scanning(device) == TRUE)
+               return -EALREADY;
+
        connman_device_ref(device);
 
        ret = g_supplicant_interface_scan(wifi->interface, NULL,
@@ -822,6 +825,9 @@ static int wifi_scan_fast(struct connman_device *device)
        if (wifi->tethering == TRUE)
                return 0;
 
+       if (connman_device_get_scanning(device) == TRUE)
+               return -EALREADY;
+
        driver_max_ssids = g_supplicant_interface_get_max_scan_ssids(
                                                        wifi->interface);
        DBG("max ssids %d", driver_max_ssids);
@@ -875,6 +881,9 @@ static int wifi_scan_hidden(struct connman_device *device,
        if (ssid == NULL || ssid_len == 0 || ssid_len > 32)
                return -EINVAL;
 
+       if (connman_device_get_scanning(device) == TRUE)
+               return -EALREADY;
+
        scan_params = g_try_malloc0(sizeof(GSupplicantScanParams));
        if (scan_params == NULL)
                return -ENOMEM;