diff options
| author | Andrej Mihajlov <and@mullvad.net> | 2022-03-22 12:28:06 +0100 |
|---|---|---|
| committer | Andrej Mihajlov <and@mullvad.net> | 2022-03-24 14:01:50 +0100 |
| commit | bbb46daad8bc9649f6ff5909911c097f59471efb (patch) | |
| tree | 218408116aeccf07242b033cf312d67e03015dbb /ios | |
| parent | 2bdf1c542834a1f92a7be16e6db140ec01007586 (diff) | |
| download | mullvadvpn-bbb46daad8bc9649f6ff5909911c097f59471efb.tar.xz mullvadvpn-bbb46daad8bc9649f6ff5909911c097f59471efb.zip | |
TunnelMonitor: avoid double logging the "stop" operation since stopNoQueue() is called from deinit too
Diffstat (limited to 'ios')
| -rw-r--r-- | ios/PacketTunnel/TunnelMonitor.swift | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/ios/PacketTunnel/TunnelMonitor.swift b/ios/PacketTunnel/TunnelMonitor.swift index 2c5049f919..bec23409f0 100644 --- a/ios/PacketTunnel/TunnelMonitor.swift +++ b/ios/PacketTunnel/TunnelMonitor.swift @@ -34,6 +34,7 @@ final class TunnelMonitor { private var firstAttemptDate: Date? private var lastAttemptDate: Date? private var lastError: Pinger.Error? + private var isStarted = false private var isPinging = false private var logger = Logger(label: "TunnelMonitor") @@ -81,14 +82,15 @@ final class TunnelMonitor { } private func startNoQueue(address pingAddress: IPv4Address) { - if address == nil { - logger.debug("Start tunnel monitor with address: \(pingAddress).") - } else { + if isStarted { logger.debug("Restart tunnel monitor with address: \(pingAddress).") + } else { + logger.debug("Start tunnel monitor with address: \(pingAddress).") } stopNoQueue(forRestart: true) + isStarted = true address = pingAddress networkBytesReceived = 0 firstAttemptDate = Date() @@ -106,10 +108,11 @@ final class TunnelMonitor { } private func stopNoQueue(forRestart: Bool) { - if !forRestart { + if isStarted && !forRestart { logger.debug("Stop tunnel monitor.") } + isStarted = false address = nil firstAttemptDate = nil lastAttemptDate = nil |
