Merge branch 'floating-reconnection-issues'

This commit is contained in:
Davide De Rosa 2019-03-08 13:37:05 +01:00
commit ec1a0bca3a
2 changed files with 10 additions and 6 deletions

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
@ -456,9 +462,7 @@ extension TunnelKitProvider: SessionProxyDelegate {
public func sessionDidStop(_: SessionProxy, shouldReconnect: Bool) {
log.info("Session did stop")
if shouldReconnect {
reasserting = true
}
reasserting = shouldReconnect
socket?.shutdown()
}

View File

@ -979,7 +979,7 @@ public class SessionProxy {
if let error = error {
self?.queue.sync {
log.error("Failed LINK write during control flush: \(error)")
self?.deferStop(.reconnect, SessionError.failedLinkWrite)
self?.deferStop(.shutdown, SessionError.failedLinkWrite)
return
}
}
@ -1097,7 +1097,7 @@ public class SessionProxy {
if let error = error {
self?.queue.sync {
log.error("Data: Failed LINK write during send data: \(error)")
self?.deferStop(.reconnect, SessionError.failedLinkWrite)
self?.deferStop(.shutdown, SessionError.failedLinkWrite)
return
}
}
@ -1143,7 +1143,7 @@ public class SessionProxy {
if let error = error {
self?.queue.sync {
log.error("Failed LINK write during send ack for packetId \(controlPacket.packetId): \(error)")
self?.deferStop(.reconnect, SessionError.failedLinkWrite)
self?.deferStop(.shutdown, SessionError.failedLinkWrite)
return
}
}