summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrik Flykt <patrik.flykt@linux.intel.com>2012-06-15 14:13:47 +0300
committerPatrik Flykt <patrik.flykt@linux.intel.com>2012-06-18 10:59:20 +0300
commite28dffca0bf6a1d0dcc69e4abb52a22e0b0578be (patch)
tree73b2b43531f109b0ee99f39b6a8beaaf0db94680
parentfe83d954f0a1a80e9e48008e0465edaaf0cd65ea (diff)
downloadconnman-e28dffca0bf6a1d0dcc69e4abb52a22e0b0578be.tar.gz
connman-e28dffca0bf6a1d0dcc69e4abb52a22e0b0578be.tar.bz2
connman-e28dffca0bf6a1d0dcc69e4abb52a22e0b0578be.zip
technology: Disable technology when the last device is unpowered
Reply via D-Bus to the caller and send the technology 'Powered' property set to FALSE only after the last device has been powered off. Update code but not behavior in __connman_technology_enabled() so that the logic looks the same as in __connman_technology_disabled().
-rw-r--r--src/technology.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/technology.c b/src/technology.c
index 635c7b0d..be688f2f 100644
--- a/src/technology.c
+++ b/src/technology.c
@@ -1131,8 +1131,10 @@ int __connman_technology_enabled(enum connman_service_type type)
if (technology == NULL)
return -ENXIO;
- if (__sync_fetch_and_add(&technology->enabled, 1) == 0)
- powered_changed(technology);
+ if (__sync_fetch_and_add(&technology->enabled, 1) != 0)
+ return -EALREADY;
+
+ powered_changed(technology);
if (technology->pending_reply != NULL) {
g_dbus_send_reply(connection, technology->pending_reply, DBUS_TYPE_INVALID);
@@ -1153,6 +1155,9 @@ int __connman_technology_disabled(enum connman_service_type type)
if (technology == NULL)
return -ENXIO;
+ if (__sync_fetch_and_sub(&technology->enabled, 1) != 1)
+ return -EINPROGRESS;
+
if (technology->pending_reply != NULL) {
g_dbus_send_reply(connection, technology->pending_reply, DBUS_TYPE_INVALID);
dbus_message_unref(technology->pending_reply);
@@ -1161,8 +1166,7 @@ int __connman_technology_disabled(enum connman_service_type type)
technology->pending_timeout = 0;
}
- if (__sync_fetch_and_sub(&technology->enabled, 1) == 1)
- powered_changed(technology);
+ powered_changed(technology);
return 0;
}