From 3d44fcb8b3a47d83a9782a0c881eb606ea539894 Mon Sep 17 00:00:00 2001 From: Dmitriy Ryajov Date: Sat, 28 Nov 2020 09:48:06 -0600 Subject: [PATCH] use cancelAndAwait to mitigate further hangs (#459) --- libp2p/protocols/secure/secure.nim | 2 +- libp2p/transports/tcptransport.nim | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libp2p/protocols/secure/secure.nim b/libp2p/protocols/secure/secure.nim index 3809ae089..5fcfeb9dd 100644 --- a/libp2p/protocols/secure/secure.nim +++ b/libp2p/protocols/secure/secure.nim @@ -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()) diff --git a/libp2p/transports/tcptransport.nim b/libp2p/transports/tcptransport.nim index 48f0e57ce..53b60e6af 100644 --- a/libp2p/transports/tcptransport.nim +++ b/libp2p/transports/tcptransport.nim @@ -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