P.S. I did email the wrong patch files, please ignore the old one. Ignore any scanning happen from supplicant, this usually happen when supplicant start association steps which include scanning, In this step we don't want to update network list after scan since we are already in process of connection. --- include/device.h | 2 ++ plugins/wifi.c | 32 ++++++++++++++++++++++++++++---- src/device.c | 5 +++++ 3 files changed, 35 insertions(+), 4 deletions(-)
diff --git a/include/device.h b/include/device.h index c5e005d..c166a46 100644 --- a/include/device.h +++ b/include/device.h @@ -73,6 +73,8 @@ int connman_device_set_powered(struct connman_device *device, int connman_device_set_scanning(struct connman_device *device, connman_bool_t scanning); +void connman_device_reset_scanning(struct connman_device *device); + int connman_device_set_disconnected(struct connman_device *device, connman_bool_t disconnected); connman_bool_t connman_device_get_disconnected(struct connman_device *device); diff --git a/plugins/wifi.c b/plugins/wifi.c index 62d9216..2ce60d5 100644 --- a/plugins/wifi.c +++ b/plugins/wifi.c @@ -65,6 +65,7 @@ struct wifi_data { GSupplicantState state; connman_bool_t connected; connman_bool_t disconnecting; + connman_bool_t scan_requested; int index; unsigned flags; unsigned int watch; @@ -168,6 +169,8 @@ static void wifi_remove(struct connman_device *device) DBG("device %p", device); + wifi->scan_requested = FALSE; + if (wifi->pending_network != NULL) { connman_network_unref(wifi->pending_network); wifi->pending_network = NULL; @@ -235,6 +238,7 @@ static int wifi_disable(struct connman_device *device) wifi->connected = FALSE; wifi->disconnecting = FALSE; + wifi->scan_requested = FALSE; if (wifi->pending_network != NULL) { connman_network_unref(wifi->pending_network); @@ -250,20 +254,41 @@ static void scan_callback(int result, GSupplicantInterface *interface, void *user_data) { struct connman_device *device = user_data; + struct wifi_data *wifi = connman_device_get_data(device); DBG("result %d", result); + connman_error("scan_callback result %d", result); + + if (wifi == NULL) + return; + + if (result < 0) { + wifi->scan_requested = FALSE; + connman_device_reset_scanning(device); + return; + } + + if (wifi->scan_requested == TRUE) + connman_device_set_scanning(device, FALSE); - connman_device_set_scanning(device, FALSE); + wifi->scan_requested = FALSE; } static int wifi_scan(struct connman_device *device) { struct wifi_data *wifi = connman_device_get_data(device); + int err; DBG("device %p %p", device, wifi->interface); - return g_supplicant_interface_scan(wifi->interface, scan_callback, + wifi->scan_requested = TRUE; + + err = g_supplicant_interface_scan(wifi->interface, scan_callback, device); + if (err < 0) + wifi->scan_requested = FALSE; + + return err; } static struct connman_device_driver wifi_ng_driver = { @@ -366,7 +391,6 @@ static void interface_state(GSupplicantInterface *interface) switch (state) { case G_SUPPLICANT_STATE_SCANNING: - connman_device_set_scanning(device, TRUE); break; case G_SUPPLICANT_STATE_AUTHENTICATING: @@ -441,7 +465,7 @@ static void scan_started(GSupplicantInterface *interface) if (wifi == NULL) return; - if (wifi->device) + if (wifi->device && wifi->scan_requested == TRUE) connman_device_set_scanning(wifi->device, TRUE); } diff --git a/src/device.c b/src/device.c index 6eef940..9d99a8f 100644 --- a/src/device.c +++ b/src/device.c @@ -859,6 +859,11 @@ int connman_device_set_scanning(struct connman_device *device, return 0; } +void connman_device_reset_scanning(struct connman_device *device) +{ + device->scanning = FALSE; +} + /** * connman_device_set_disconnected: * @device: device structure -- 1.7.3.3 _______________________________________________ connman mailing list connman@connman.net http://lists.connman.net/listinfo/connman