diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2009-07-19 20:07:12 +0200 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2009-07-19 20:07:12 +0200 |
commit | 1a034a2281665b7fad6442a9136a43fc2be87db4 (patch) | |
tree | 169b1041e5b4b552e8ba4bbe0460c75a343b4892 | |
parent | efd47603b179119a09b7306efcd1f139f754bb8d (diff) | |
download | connman-1a034a2281665b7fad6442a9136a43fc2be87db4.tar.gz connman-1a034a2281665b7fad6442a9136a43fc2be87db4.tar.bz2 connman-1a034a2281665b7fad6442a9136a43fc2be87db4.zip |
Fix handling of enabled notifications with async powered changes
-rw-r--r-- | src/device.c | 41 |
1 files changed, 27 insertions, 14 deletions
diff --git a/src/device.c b/src/device.c index d95c027c..f8413596 100644 --- a/src/device.c +++ b/src/device.c @@ -293,7 +293,8 @@ static int set_powered(struct connman_device *device, connman_bool_t powered) if (powered == TRUE) { if (driver->enable) { err = driver->enable(device); - __connman_notifier_enable(type); + if (err == 0) + __connman_notifier_enable(type); } else err = -EINVAL; } else { @@ -303,7 +304,8 @@ static int set_powered(struct connman_device *device, connman_bool_t powered) if (driver->disable) { err = driver->disable(device); - __connman_notifier_disable(type); + if (err == 0) + __connman_notifier_disable(type); } else err = -EINVAL; } @@ -851,26 +853,25 @@ static void unregister_interface(struct connman_element *element) static void device_enable(struct connman_device *device) { - enum connman_service_type type; - DBG("device %p", device); if (device->powered == TRUE) return; - type = __connman_device_get_service_type(device); - if (device->driver->enable) { - if (device->driver->enable(device) == 0) + if (device->driver->enable(device) == 0) { + enum connman_service_type type; + device->powered = TRUE; - __connman_notifier_enable(type); + + type = __connman_device_get_service_type(device); + __connman_notifier_enable(type); + } } } static void device_disable(struct connman_device *device) { - enum connman_service_type type; - DBG("device %p", device); if (device->powered == FALSE) @@ -878,12 +879,15 @@ static void device_disable(struct connman_device *device) g_hash_table_remove_all(device->networks); - type = __connman_device_get_service_type(device); - if (device->driver->disable) { - if (device->driver->disable(device) == 0) + if (device->driver->disable(device) == 0) { + enum connman_service_type type; + device->powered = FALSE; - __connman_notifier_disable(type); + + type = __connman_device_get_service_type(device); + __connman_notifier_disable(type); + } } } @@ -1353,6 +1357,8 @@ connman_bool_t connman_device_get_secondary(struct connman_device *device) int connman_device_set_powered(struct connman_device *device, connman_bool_t powered) { + enum connman_service_type type; + DBG("driver %p powered %d", device, powered); if (device->timeout > 0) { @@ -1373,6 +1379,13 @@ int connman_device_set_powered(struct connman_device *device, device->powered = powered; + type = __connman_device_get_service_type(device); + + if (device->powered == TRUE) + __connman_notifier_enable(type); + else + __connman_notifier_disable(type); + if (device->registered == FALSE) return 0; |