aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoopesh Chander <roop@roopc.net>2018-12-13 23:34:00 +0530
committerRoopesh Chander <roop@roopc.net>2018-12-13 23:34:00 +0530
commit3bddab8a9e53a9bc5fe71bb558d4d23edf9643b5 (patch)
tree2969dce94edba52ca621d3cbbe86a010e380e181
parentTunnelsManager: Reintroduce waiting for another tunnel to deactivate (diff)
downloadwireguard-apple-3bddab8a9e53a9bc5fe71bb558d4d23edf9643b5.tar.xz
wireguard-apple-3bddab8a9e53a9bc5fe71bb558d4d23edf9643b5.zip
TunnelsManager: Fix race between multiple startActivation() calls
After startActivate() is called on a waiting tunnel, user might turn on a different tunnel before the waiting tunnel's status gets updated. This fix prevents that from happening. Signed-off-by: Roopesh Chander <roop@roopc.net>
-rw-r--r--WireGuard/WireGuard/Tunnel/TunnelsManager.swift2
1 files changed, 2 insertions, 0 deletions
diff --git a/WireGuard/WireGuard/Tunnel/TunnelsManager.swift b/WireGuard/WireGuard/Tunnel/TunnelsManager.swift
index 8f53ef9a..25d894b0 100644
--- a/WireGuard/WireGuard/Tunnel/TunnelsManager.swift
+++ b/WireGuard/WireGuard/Tunnel/TunnelsManager.swift
@@ -392,6 +392,8 @@ class TunnelContainer: NSObject {
wg_log(.debug, message: "startActivation: Entering (tunnel: \(self.name))")
+ self.status = .activating // Ensure that no other tunnel can attempt activation until this tunnel is done trying
+
guard tunnelProvider.isEnabled else {
// In case the tunnel had gotten disabled, re-enable and save it,
// then call this function again.