Double check reasserting during reconnection

A forced shutdown might happen during the recovery interval (1s).
This commit is contained in:
Davide De Rosa 2019-03-08 13:19:26 +01:00
parent 70ed2a4d83
commit 6b29c9e06c

View File

@ -403,6 +403,12 @@ extension TunnelKitProvider: GenericSocketDelegate {
if reasserting {
log.debug("Disconnection is recoverable, tunnel will reconnect in \(reconnectionDelay) milliseconds...")
tunnelQueue.schedule(after: .milliseconds(reconnectionDelay)) {
// give up if reasserting cleared in the meantime
guard self.reasserting else {
return
}
self.connectTunnel(upgradedSocket: upgradedSocket, preferredAddress: socket.remoteAddress)
}
return