Avoid double socket destroy on timed-out uTP SYN-ACK (#619)

This commit is contained in:
Kim De Mey 2023-06-15 04:26:22 -06:00 committed by GitHub
parent d766fc435e
commit cea23299be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -576,9 +576,13 @@ proc checkTimeouts(socket: UtpSocket) =
retransmitCount = socket.retransmitCount
if socket.state == SynSent and (not socket.connectionFuture.finished()):
socket.connectionFuture.fail(newException(ConnectionError, "Connection to peer timed out"))
# Note: The socket connect code will already call socket.destroy when
# ConnectionError gets raised, no need to do it here.
socket.connectionFuture.fail(newException(
ConnectionError, "Connection to peer timed out"))
else:
socket.destroy()
socket.destroy()
return
let newTimeout = socket.retransmitTimeout * 2