summaryrefslogtreecommitdiff
path: root/src/tethering.c
diff options
context:
space:
mode:
authorSamuel Ortiz <sameo@linux.intel.com>2010-11-24 15:45:47 +0100
committerSamuel Ortiz <sameo@linux.intel.com>2010-11-24 15:45:47 +0100
commitee179cc1006ca57cb3f1942a4d54ca42c1da744c (patch)
treedb39da07847de4439ccf2428d2e77ff8f05ee906 /src/tethering.c
parent31f83e0d8ffb3b0ed002ab9709d114e8e237d398 (diff)
downloadconnman-ee179cc1006ca57cb3f1942a4d54ca42c1da744c.tar.gz
connman-ee179cc1006ca57cb3f1942a4d54ca42c1da744c.tar.bz2
connman-ee179cc1006ca57cb3f1942a4d54ca42c1da744c.zip
tethering: Remove bridge asynchronously
The tethering bridge should be removed once the technology signals that tethering is actually disabled.
Diffstat (limited to 'src/tethering.c')
-rw-r--r--src/tethering.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/tethering.c b/src/tethering.c
index 762bf1a3..e8d09c07 100644
--- a/src/tethering.c
+++ b/src/tethering.c
@@ -297,10 +297,16 @@ void __connman_tethering_set_enabled(void)
DBG("enabled %d", tethering_enabled + 1);
if (g_atomic_int_exchange_and_add(&tethering_enabled, 1) == 0) {
- err = enable_bridge(BRIDGE_NAME);
+ err = create_bridge(BRIDGE_NAME);
if (err < 0)
return;
+ err = enable_bridge(BRIDGE_NAME);
+ if (err < 0) {
+ remove_bridge(BRIDGE_NAME);
+ return;
+ }
+
tethering_dhcp_server =
dhcp_server_start(BRIDGE_NAME,
BRIDGE_IP, BRIDGE_SUBNET,
@@ -308,6 +314,7 @@ void __connman_tethering_set_enabled(void)
24 * 3600, BRIDGE_DNS);
if (tethering_dhcp_server == NULL) {
disable_bridge(BRIDGE_NAME);
+ remove_bridge(BRIDGE_NAME);
return;
}
@@ -331,6 +338,8 @@ void __connman_tethering_set_disabled(void)
disable_bridge(BRIDGE_NAME);
+ remove_bridge(BRIDGE_NAME);
+
DBG("tethering stopped");
}
}
@@ -340,13 +349,10 @@ int __connman_tethering_set_status(connman_bool_t status)
if (status == tethering_status)
return -EALREADY;
- if (status == TRUE) {
- create_bridge(BRIDGE_NAME);
+ if (status == TRUE)
__connman_technology_enable_tethering(BRIDGE_NAME);
- } else {
+ else
__connman_technology_disable_tethering(BRIDGE_NAME);
- remove_bridge(BRIDGE_NAME);
- }
tethering_status = status;