use cancelAndAwait to mitigate further hangs (#459)
This commit is contained in:
parent
a8f5f7a8bb
commit
3d44fcb8b3
|
@ -81,7 +81,7 @@ proc handleConn*(s: Secure,
|
||||||
let futs = @[conn.join(), sconn.join()]
|
let futs = @[conn.join(), sconn.join()]
|
||||||
await futs[0] or futs[1]
|
await futs[0] or futs[1]
|
||||||
for f in futs:
|
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(
|
await allFuturesThrowing(
|
||||||
sconn.close(), conn.close())
|
sconn.close(), conn.close())
|
||||||
|
|
|
@ -88,7 +88,7 @@ proc connHandler*(t: TcpTransport,
|
||||||
let futs = @[client.join(), conn.join()]
|
let futs = @[client.join(), conn.join()]
|
||||||
await futs[0] or futs[1]
|
await futs[0] or futs[1]
|
||||||
for f in futs:
|
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,
|
trace "Cleaning up client", addrs = $client.remoteAddress,
|
||||||
conn
|
conn
|
||||||
|
|
Loading…
Reference in New Issue