timeserver: Simplify timeserver IP address checking
[framework/connectivity/connman.git] / plugins / wifi.c
index 89576b3..3cd2be2 100644 (file)
@@ -222,6 +222,8 @@ static void stop_autoscan(struct connman_device *device)
        autoscan->timeout = 0;
        autoscan->interval = 0;
 
+       connman_device_set_scanning(device, FALSE);
+
        connman_device_unref(device);
 }
 
@@ -236,6 +238,10 @@ static void wifi_remove(struct connman_device *device)
 
        stop_autoscan(device);
 
+       /* In case of a user scan, device is still referenced */
+       if (connman_device_get_scanning(device) == TRUE)
+               connman_device_unref(wifi->device);
+
        iface_list = g_list_remove(iface_list, wifi);
 
        remove_networks(device, wifi);
@@ -399,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,
@@ -816,6 +825,11 @@ static int wifi_scan_fast(struct connman_device *device)
        if (wifi->tethering == TRUE)
                return 0;
 
+       stop_autoscan(device);
+
+       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);
@@ -832,8 +846,6 @@ static int wifi_scan_fast(struct connman_device *device)
                return wifi_scan(device);
        }
 
-       stop_autoscan(device);
-
        connman_device_ref(device);
        ret = g_supplicant_interface_scan(wifi->interface, scan_params,
                                                scan_callback, device);
@@ -869,6 +881,11 @@ static int wifi_scan_hidden(struct connman_device *device,
        if (ssid == NULL || ssid_len == 0 || ssid_len > 32)
                return -EINVAL;
 
+       stop_autoscan(device);
+
+       if (connman_device_get_scanning(device) == TRUE)
+               return -EALREADY;
+
        scan_params = g_try_malloc0(sizeof(GSupplicantScanParams));
        if (scan_params == NULL)
                return -ENOMEM;
@@ -896,8 +913,6 @@ static int wifi_scan_hidden(struct connman_device *device,
        hidden->passphrase = g_strdup(passphrase);
        wifi->hidden = hidden;
 
-       stop_autoscan(device);
-
        connman_device_ref(device);
        ret = g_supplicant_interface_scan(wifi->interface, scan_params,
                        scan_callback, device);