summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-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()