less leak prone cleanup (#447)
* less leak prone cleanup * fix double allFinished
This commit is contained in:
parent
6cc3f4283a
commit
69ae24dc8d
|
@ -13,7 +13,8 @@ import ../protocol,
|
||||||
../../stream/streamseq,
|
../../stream/streamseq,
|
||||||
../../stream/connection,
|
../../stream/connection,
|
||||||
../../multiaddress,
|
../../multiaddress,
|
||||||
../../peerinfo
|
../../peerinfo,
|
||||||
|
../../errors
|
||||||
|
|
||||||
export protocol
|
export protocol
|
||||||
|
|
||||||
|
@ -77,8 +78,8 @@ proc handleConn*(s: Secure,
|
||||||
|
|
||||||
proc cleanup() {.async.} =
|
proc cleanup() {.async.} =
|
||||||
try:
|
try:
|
||||||
await conn.join()
|
await conn.join() or sconn.join()
|
||||||
await sconn.close()
|
await allFuturesThrowing(sconn.close(), conn.close())
|
||||||
except CancelledError:
|
except CancelledError:
|
||||||
# This is top-level procedure which will work as separate task, so it
|
# This is top-level procedure which will work as separate task, so it
|
||||||
# do not need to propagate CancelledError.
|
# do not need to propagate CancelledError.
|
||||||
|
|
|
@ -77,12 +77,9 @@ proc connHandler*(t: TcpTransport,
|
||||||
trace "Cleaning up client", addrs = $client.remoteAddress,
|
trace "Cleaning up client", addrs = $client.remoteAddress,
|
||||||
conn
|
conn
|
||||||
|
|
||||||
if not(isNil(conn) and conn.closed()):
|
|
||||||
await conn.close()
|
|
||||||
|
|
||||||
t.clients[dir].keepItIf( it != client )
|
t.clients[dir].keepItIf( it != client )
|
||||||
if not(isNil(client) and client.closed()):
|
await allFuturesThrowing(
|
||||||
await client.closeWait()
|
conn.close(), client.closeWait())
|
||||||
|
|
||||||
trace "Cleaned up client", addrs = $client.remoteAddress,
|
trace "Cleaned up client", addrs = $client.remoteAddress,
|
||||||
conn
|
conn
|
||||||
|
|
Loading…
Reference in New Issue