From 489cd9ddd7fd36c7b84e184cdf816198328be776 Mon Sep 17 00:00:00 2001 From: Samuel Ortiz Date: Tue, 3 Aug 2010 16:03:33 +0200 Subject: [PATCH 3/5] Toggle the powered_pending device flag only if driver op succeeds --- src/device.c | 16 ++++++++++------ 1 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/device.c b/src/device.c index 33ee896..e3d4d04 100644 --- a/src/device.c +++ b/src/device.c @@ -206,12 +206,14 @@ int __connman_device_enable(struct connman_device *device) if (device->powered_pending == TRUE) return -EALREADY; - device->powered_pending = TRUE; - err = device->driver->enable(device); - if (err < 0) + if (err < 0) { + if (err == -EINPROGRESS) + device->powered_pending = TRUE; return err; + } + device->powered_pending = TRUE; device->powered = TRUE; __connman_technology_enable_device(device); @@ -234,8 +236,6 @@ int __connman_device_disable(struct connman_device *device) if (device->powered_pending == FALSE) return -EALREADY; - device->powered_pending = FALSE; - device->reconnect = FALSE; clear_scan_trigger(device); @@ -243,9 +243,13 @@ int __connman_device_disable(struct connman_device *device) g_hash_table_remove_all(device->networks); err = device->driver->disable(device); - if (err < 0) + if (err < 0) { + if (err == -EINPROGRESS) + device->powered_pending = FALSE; return err; + } + device->powered_pending = FALSE; device->powered = FALSE; __connman_technology_disable_device(device); -- 1.7.1