GSList *networks;
GSupplicantInterface *interface;
GSupplicantState state;
- connman_bool_t disabling;
connman_bool_t connected;
connman_bool_t disconnecting;
connman_bool_t tethering;
if (wifi == NULL)
return -ENOMEM;
- wifi->disabling = FALSE;
wifi->connected = FALSE;
wifi->disconnecting = FALSE;
wifi->tethering = FALSE;
{
struct connman_device *device = user_data;
struct wifi_data *wifi = connman_device_get_data(device);
+ connman_bool_t scanning;
DBG("result %d wifi %p", result, wifi);
if (result < 0)
connman_device_reset_scanning(device);
- connman_device_set_scanning(device, FALSE);
+ scanning = connman_device_get_scanning(device);
+
+ if (scanning == TRUE)
+ connman_device_set_scanning(device, FALSE);
if (result != -ENOLINK)
start_autoscan(device);
/*
- * If we are here then we were scanning; however, if we are also
- * mid-flight disabling the interface, then wifi_disable has
- * already unreferenced the device and we needn't do it here.
+ * If we are here then we were scanning; however, if we are
+ * also mid-flight disabling the interface, then wifi_disable
+ * has already cleared the device scanning state and
+ * unreferenced the device, obviating the need to do it here.
*/
- if (wifi->disabling != TRUE)
+ if (scanning == TRUE)
connman_device_unref(device);
}
}
}
-/*
- * The sole function of this callback is to avoid a race between scan completion
- * and wifi_disable that can otherwise cause a reference count underflow if the
- * disabling state is not tracked and observed.
- */
-static void interface_remove_callback(int result,
- GSupplicantInterface *interface,
- void *user_data)
-{
- struct wifi_data *wifi = user_data;
-
- DBG("result %d ifname %s, wifi %p", result,
- g_supplicant_interface_get_ifname(interface),
- wifi);
-
- if (result < 0 || wifi == NULL)
- return;
-
- wifi->disabling = FALSE;
-}
-
static int wifi_enable(struct connman_device *device)
{
struct wifi_data *wifi = connman_device_get_data(device);
if (ret < 0)
return ret;
- wifi->disabling = FALSE;
-
return -EINPROGRESS;
}
remove_networks(device, wifi);
- ret = g_supplicant_interface_remove(wifi->interface,
- interface_remove_callback,
- wifi);
+ ret = g_supplicant_interface_remove(wifi->interface, NULL, NULL);
if (ret < 0)
return ret;
- wifi->disabling = TRUE;
-
return -EINPROGRESS;
}