diff options
author | 2019-01-26 14:31:38 +0530 | |
---|---|---|
committer | 2019-01-26 14:31:42 +0530 | |
commit | a796c6c485d7243d836c7067e9db76a705ec9847 (patch) | |
tree | 0b052b4bf03429683ccf1f63d2a857e47287aa59 /WireGuard | |
parent | macOS: Delay .deactivated status to workaround system bug (diff) | |
download | wireguard-apple-a796c6c485d7243d836c7067e9db76a705ec9847.tar.xz wireguard-apple-a796c6c485d7243d836c7067e9db76a705ec9847.zip |
TunnelsManager: Invoke reload() in a subsequent runloop
Signed-off-by: Roopesh Chander <roop@roopc.net>
Diffstat (limited to 'WireGuard')
-rw-r--r-- | WireGuard/WireGuard/Tunnel/TunnelsManager.swift | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/WireGuard/WireGuard/Tunnel/TunnelsManager.swift b/WireGuard/WireGuard/Tunnel/TunnelsManager.swift index 29d486a..3120f7d 100644 --- a/WireGuard/WireGuard/Tunnel/TunnelsManager.swift +++ b/WireGuard/WireGuard/Tunnel/TunnelsManager.swift @@ -340,7 +340,13 @@ class TunnelsManager { func startObservingTunnelConfigurations() { configurationsObservationToken = NotificationCenter.default.addObserver(forName: .NEVPNConfigurationChange, object: nil, queue: OperationQueue.main) { [weak self] _ in - self?.reload() + DispatchQueue.main.async { [weak self] in + // We schedule reload() in a subsequent runloop to ensure that the completion handler of loadAllFromPreferences + // (reload() calls loadAllFromPreferences) is called after the completion handler of the saveToPreferences or + // removeFromPreferences call, if any, that caused this notification to fire. This notification can also fire + // as a result of a tunnel getting added or removed outside of the app. + self?.reload() + } } } |