Hi Mohamed, On Wed, Jan 19, 2011 at 04:25:00PM -0800, Mohamed Abbas wrote: > The proplem related unbalnced call to connman_device_set_scanning with > TRUE/FALSE this will end up leaving device->scanning in wrong state > causing autoconnect to be not called. This patch also add > connman_device_reset_scannind api to reset device->scanning to false > if scan for some reason did not start. > --- > include/device.h | 1 + > plugins/wifi.c | 18 ++++++++++++------ > src/device.c | 10 ++++++++++ > 3 files changed, 23 insertions(+), 6 deletions(-) > > diff --git a/include/device.h b/include/device.h > index c5e005d..5cb34d7 100644 > --- a/include/device.h > +++ b/include/device.h > @@ -72,6 +72,7 @@ int connman_device_set_powered(struct connman_device > *device, > connman_bool_t powered); > 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); > diff --git a/plugins/wifi.c b/plugins/wifi.c > index 040d2f9..9ffac0d 100644 > --- a/plugins/wifi.c > +++ b/plugins/wifi.c > @@ -253,17 +253,27 @@ static void scan_callback(int result, > GSupplicantInterface *interface, > > DBG("result %d", result); > > - connman_device_set_scanning(device, FALSE); > + if (result < 0) > + connman_device_reset_scanning(device); > + else > + connman_device_set_scanning(device, FALSE); > } > > static int wifi_scan(struct connman_device *device) > { > struct wifi_data *wifi = connman_device_get_data(device); > + int ret; > > DBG("device %p %p", device, wifi->interface); > > - return g_supplicant_interface_scan(wifi->interface, scan_callback, > + connman_device_set_scanning(device, TRUE); > + > + ret = g_supplicant_interface_scan(wifi->interface, scan_callback, > device); > + if (ret < 0) > + connman_device_reset_scanning(device); > + > + return ret; Could we please do:
if (ret == 0) connman_device_set_scanning(device, TRUE); instead ? > } > > static struct connman_device_driver wifi_ng_driver = { > @@ -366,7 +376,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: > @@ -440,9 +449,6 @@ static void scan_started(GSupplicantInterface *interface) > > if (wifi == NULL) > return; > - > - if (wifi->device) > - connman_device_set_scanning(wifi->device, TRUE); > } > > static void scan_finished(GSupplicantInterface *interface) > diff --git a/src/device.c b/src/device.c > index 6eef940..8760a6b 100644 > --- a/src/device.c > +++ b/src/device.c > @@ -820,6 +820,16 @@ connman_bool_t __connman_device_scanning(struct > connman_device *device) > return device->scanning; > } > > +/* scan failed just reset device->scanning without calling > + * __connman_device_cleanup_networks since this will cause > + * al network to be lost since there are no scan result. > + */ > +void connman_device_reset_scanning(struct connman_device *device) > +{ > + > + device->scanning = FALSE; > +} I see your point. Could you please go through all device networks and mark them back as available ? Cheers, Samuel. -- Intel Open Source Technology Centre http://oss.intel.com/ _______________________________________________ connman mailing list connman@connman.net http://lists.connman.net/listinfo/connman