]> git.ipfire.org Git - thirdparty/wireguard-apple.git/commitdiff
NetworkExtension: close context before turning off go
authorJason A. Donenfeld <Jason@zx2c4.com>
Wed, 31 Oct 2018 02:03:00 +0000 (03:03 +0100)
committerJason A. Donenfeld <Jason@zx2c4.com>
Wed, 31 Oct 2018 02:03:00 +0000 (03:03 +0100)
The go turnOff code waits for all readers to have completed. In order to
make readers complete, we must send the signal to unblock the request.
Thus, we must reorder these.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
WireGuard/WireGuardNetworkExtension/PacketTunnelProvider.swift

index a961f7647986b5b89414ca89072bc34a954daf3b..5f19fb139f55466b2c93dbdd57021d0adf7a261a 100644 (file)
@@ -125,10 +125,10 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
     /// Begin the process of stopping the tunnel.
     override func stopTunnel(with reason: NEProviderStopReason, completionHandler: @escaping () -> Void) {
         os_log("Stopping tunnel", log: OSLog.default, type: .info)
+        wgContext?.closeTunnel()
         if let handle = wgHandle {
             wgTurnOff(handle)
         }
-        wgContext?.closeTunnel()
         completionHandler()
     }