mirror of
https://github.com/vacp2p/nim-quic.git
synced 2026-01-08 21:38:05 -05:00
handle dial cancellation (#113)
This commit is contained in:
@@ -119,7 +119,8 @@ proc dial*(
|
||||
try:
|
||||
connection.startHandshake()
|
||||
await connection.waitForHandshake()
|
||||
except TimeOutError as exc:
|
||||
except CatchableError as exc:
|
||||
# whatever error happens we need to destroy tlsBackend to free resources
|
||||
tlsBackend.destroy()
|
||||
raise exc
|
||||
|
||||
|
||||
@@ -173,7 +173,17 @@ proc waitForHandshake*(
|
||||
let errFut = connection.quic.error.waitEvents(key)
|
||||
let timeoutFut = connection.quic.timeout.wait()
|
||||
let handshakeFut = connection.quic.handshake.wait()
|
||||
let raceFut = await race(handshakeFut, timeoutFut, errFut)
|
||||
let raceFut =
|
||||
try:
|
||||
await race(handshakeFut, timeoutFut, errFut)
|
||||
except CancelledError as e:
|
||||
let connCloseFut = connection.close()
|
||||
handshakeFut.cancelSoon()
|
||||
errFut.cancelSoon()
|
||||
timeoutFut.cancelSoon()
|
||||
await connCloseFut
|
||||
raise e
|
||||
|
||||
if raceFut == timeoutFut:
|
||||
let connCloseFut = connection.close()
|
||||
errFut.cancelSoon()
|
||||
|
||||
Reference in New Issue
Block a user