use cancelAndAwait to mitigate further hangs (#459)

This commit is contained in:
Dmitriy Ryajov 2020-11-28 09:48:06 -06:00 committed by GitHub
parent a8f5f7a8bb
commit 3d44fcb8b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -81,7 +81,7 @@ proc handleConn*(s: Secure,
let futs = @[conn.join(), sconn.join()]
await futs[0] or futs[1]
for f in futs:
if not f.finished: f.cancel # cancel outstanding join()
if not f.finished: await f.cancelAndWait() # cancel outstanding join()
await allFuturesThrowing(
sconn.close(), conn.close())

View File

@ -88,7 +88,7 @@ proc connHandler*(t: TcpTransport,
let futs = @[client.join(), conn.join()]
await futs[0] or futs[1]
for f in futs:
if not f.finished: f.cancel # cancel outstanding join()
if not f.finished: await f.cancelAndWait() # cancel outstanding join()
trace "Cleaning up client", addrs = $client.remoteAddress,
conn