Retain self weakly for shutdown on timeout

This commit is contained in:
Davide De Rosa 2019-05-02 13:13:20 +02:00
parent 705be661b0
commit d44d08c95e
1 changed files with 7 additions and 4 deletions

View File

@ -245,12 +245,15 @@ open class TunnelKitProvider: NEPacketTunnelProvider {
} }
pendingStopHandler = completionHandler pendingStopHandler = completionHandler
tunnelQueue.schedule(after: .milliseconds(shutdownTimeout)) { tunnelQueue.schedule(after: .milliseconds(shutdownTimeout)) { [weak self] in
guard let pendingHandler = self.pendingStopHandler else { guard let weakSelf = self else {
return return
} }
log.warning("Tunnel not responding after \(self.shutdownTimeout) milliseconds, forcing stop") guard let pendingHandler = weakSelf.pendingStopHandler else {
self.flushLog() return
}
log.warning("Tunnel not responding after \(weakSelf.shutdownTimeout) milliseconds, forcing stop")
weakSelf.flushLog()
pendingHandler() pendingHandler()
} }
tunnelQueue.sync { tunnelQueue.sync {