Disable offline devices upon device_set_connected(TRUE) calls
authorSamuel Ortiz <sameo@linux.intel.com>
Thu, 5 Aug 2010 14:38:12 +0000 (16:38 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Fri, 6 Aug 2010 13:14:45 +0000 (15:14 +0200)
Some devices are powered up asynchronously, and one can potentially
enable offline mode while the device is not powered up yet. The
device thus needs to be turned back off when it's finally reported
to be on.

src/device.c

index c1d74b6..39d86b5 100644 (file)
@@ -1007,6 +1007,11 @@ int connman_device_set_powered(struct connman_device *device,
        else
                __connman_technology_disable_device(device);
 
+       if (device->offlinemode == TRUE && powered == TRUE) {
+               powered_changed(device);
+               return connman_device_set_powered(device, FALSE);
+       }
+
        if (device->registered == FALSE)
                return 0;
 
@@ -1070,8 +1075,10 @@ int __connman_device_enable_persistent(struct connman_device *device)
 
        err = __connman_device_enable(device);
        if (err == 0 || err == -EINPROGRESS) {
-               if (__connman_profile_get_offlinemode() == TRUE)
+               if (__connman_profile_get_offlinemode() == TRUE) {
+                       device->offlinemode = FALSE;
                        __connman_profile_set_offlinemode(FALSE, FALSE);
+               }
 
        }