summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@mullvad.net>2020-07-08 21:22:33 +0200
committerAndrej Mihajlov <and@mullvad.net>2020-07-15 14:33:00 +0200
commita5ff0e8a5b3dbbff1d8d30363c2a2d3c657337f2 (patch)
tree8aedd95e9e11063db3b92aa86acecec3649f57d8
parent641c0b95822c55019f758b164c0e0273c17f0f39 (diff)
downloadmullvadvpn-a5ff0e8a5b3dbbff1d8d30363c2a2d3c657337f2.tar.xz
mullvadvpn-a5ff0e8a5b3dbbff1d8d30363c2a2d3c657337f2.zip
Fix possible race condition in timer
-rw-r--r--ios/MullvadVPN/AutomaticKeyRotationManager.swift6
1 files changed, 5 insertions, 1 deletions
diff --git a/ios/MullvadVPN/AutomaticKeyRotationManager.swift b/ios/MullvadVPN/AutomaticKeyRotationManager.swift
index 350ef6aa80..b605b7e3da 100644
--- a/ios/MullvadVPN/AutomaticKeyRotationManager.swift
+++ b/ios/MullvadVPN/AutomaticKeyRotationManager.swift
@@ -239,7 +239,11 @@ class AutomaticKeyRotationManager {
private func scheduleRetry(wallDeadline: DispatchWallTime) {
let timerSource = DispatchSource.makeTimerSource(queue: dispatchQueue)
timerSource.setEventHandler { [weak self] in
- self?.performKeyRotation()
+ guard let self = self else { return }
+
+ if self.isAutomaticRotationEnabled {
+ self.performKeyRotation()
+ }
}
timerSource.schedule(wallDeadline: wallDeadline)