From 20a23a86dad60fe559559a36af4ba6535b3f0993 Mon Sep 17 00:00:00 2001 From: Roopesh Chander Date: Thu, 13 Dec 2018 23:34:00 +0530 Subject: [PATCH] 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. --- WireGuard/WireGuard/Tunnel/TunnelsManager.swift | 2 ++ 1 file changed, 2 insertions(+) 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.