summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrik Flykt <patrik.flykt@linux.intel.com>2012-09-07 14:55:10 +0300
committerPatrik Flykt <patrik.flykt@linux.intel.com>2012-09-13 13:42:12 +0300
commitab9cc2faadf73cb7ace797af5529b9841c6d3adc (patch)
tree6e04abf0bd06f5ef8e609ff0cef424b50641e4a5
parent98919ac6cbc7535309d308363a249a0cdfe0af22 (diff)
downloadconnman-ab9cc2faadf73cb7ace797af5529b9841c6d3adc.tar.gz
connman-ab9cc2faadf73cb7ace797af5529b9841c6d3adc.tar.bz2
connman-ab9cc2faadf73cb7ace797af5529b9841c6d3adc.zip
tethering: Reset the tethering refcount on error
Decrease the refcount with one on error.
-rw-r--r--src/tethering.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/tethering.c b/src/tethering.c
index e3432371..f3d67dfa 100644
--- a/src/tethering.c
+++ b/src/tethering.c
@@ -198,8 +198,10 @@ void __connman_tethering_set_enabled(void)
return;
err = __connman_bridge_create(BRIDGE_NAME);
- if (err < 0)
+ if (err < 0) {
+ __sync_fetch_and_sub(&tethering_enabled, 1);
return;
+ }
index = connman_inet_ifindex(BRIDGE_NAME);
dhcp_ippool = __connman_ippool_create(index, 2, 252,
@@ -207,6 +209,7 @@ void __connman_tethering_set_enabled(void)
if (dhcp_ippool == NULL) {
connman_error("Fail to create IP pool");
__connman_bridge_remove(BRIDGE_NAME);
+ __sync_fetch_and_sub(&tethering_enabled, 1);
return;
}
@@ -220,6 +223,7 @@ void __connman_tethering_set_enabled(void)
if (err < 0 && err != -EALREADY) {
__connman_ippool_unref(dhcp_ippool);
__connman_bridge_remove(BRIDGE_NAME);
+ __sync_fetch_and_sub(&tethering_enabled, 1);
return;
}
@@ -238,6 +242,7 @@ void __connman_tethering_set_enabled(void)
__connman_bridge_disable(BRIDGE_NAME);
__connman_ippool_unref(dhcp_ippool);
__connman_bridge_remove(BRIDGE_NAME);
+ __sync_fetch_and_sub(&tethering_enabled, 1);
return;
}