aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoopesh Chander <roop@roopc.net>2019-01-26 14:31:38 +0530
committerRoopesh Chander <roop@roopc.net>2019-01-26 14:31:42 +0530
commita796c6c485d7243d836c7067e9db76a705ec9847 (patch)
tree0b052b4bf03429683ccf1f63d2a857e47287aa59
parentmacOS: Delay .deactivated status to workaround system bug (diff)
downloadwireguard-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 '')
-rw-r--r--WireGuard/WireGuard/Tunnel/TunnelsManager.swift8
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()
+ }
}
}