From 3bddab8a9e53a9bc5fe71bb558d4d23edf9643b5 Mon Sep 17 00:00:00 2001 From: Roopesh Chander Date: Thu, 13 Dec 2018 23:34:00 +0530 Subject: 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 --- WireGuard/WireGuard/Tunnel/TunnelsManager.swift | 2 ++ 1 file changed, 2 insertions(+) (limited to 'WireGuard/WireGuard/Tunnel/TunnelsManager.swift') diff --git a/WireGuard/WireGuard/Tunnel/TunnelsManager.swift b/WireGuard/WireGuard/Tunnel/TunnelsManager.swift index 8f53ef9..25d894b 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. -- cgit v1.2.3-59-g8ed1b