summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@mullvad.net>2023-03-01 15:24:17 +0100
committerAndrej Mihajlov <and@mullvad.net>2023-03-03 12:01:30 +0100
commitb17e032c45e6ec4577b8a8e143b9d82715ccfd90 (patch)
treeac4563389a13f7767da2867419ebdca221e43bb6
parentfaece927955044c84bee84208c5cd95ddc22944c (diff)
downloadmullvadvpn-b17e032c45e6ec4577b8a8e143b9d82715ccfd90.tar.xz
mullvadvpn-b17e032c45e6ec4577b8a8e143b9d82715ccfd90.zip
PacketTunnel: ignore all requests to reconnect after the first call to stopTunnel()
-rw-r--r--ios/PacketTunnel/PacketTunnelProvider.swift8
1 files changed, 8 insertions, 0 deletions
diff --git a/ios/PacketTunnel/PacketTunnelProvider.swift b/ios/PacketTunnel/PacketTunnelProvider.swift
index 3228f1b44e..4a7e10e471 100644
--- a/ios/PacketTunnel/PacketTunnelProvider.swift
+++ b/ios/PacketTunnel/PacketTunnelProvider.swift
@@ -38,6 +38,10 @@ class PacketTunnelProvider: NEPacketTunnelProvider, TunnelMonitorDelegate {
/// completion handler passed into `startTunnel`.
private var isConnected = false
+ /// Raised once tunnel receives the first call to `stopTunnel()`.
+ /// Once this happens all requests to reconnect the tunnel will be ignored.
+ private var isStopping = false
+
/// Flag indicating whether network is reachable.
private var isNetworkReachable = true
@@ -256,6 +260,7 @@ class PacketTunnelProvider: NEPacketTunnelProvider, TunnelMonitorDelegate {
providerLogger.debug("Stop the tunnel: \(reason)")
dispatchQueue.async {
+ self.isStopping = true
self.cancelTunnelStartupFailureRecovery()
self.startTunnelCompletionHandler = nil
}
@@ -508,6 +513,9 @@ class PacketTunnelProvider: NEPacketTunnelProvider, TunnelMonitorDelegate {
) {
dispatchPrecondition(condition: .onQueue(dispatchQueue))
+ // Ignore all requests to reconnect once tunnel is preparing to stop.
+ guard !isStopping else { return }
+
let blockOperation = AsyncBlockOperation(dispatchQueue: dispatchQueue) { operation in
if shouldStopTunnelMonitor {
self.tunnelMonitor.stop()