Track all connections (#175)
* adding to do for future refactor * no mix conn and transport stopping or it will race * don't use intermediary vars
This commit is contained in:
parent
1819502fb5
commit
5583168965
|
@ -335,16 +335,16 @@ proc stop*(s: Switch) {.async.} =
|
|||
# we want to report erros but we do not want to fail
|
||||
# or crash here, cos we need to clean possibly MANY items
|
||||
# and any following conn/transport won't be cleaned up
|
||||
var futs = newSeq[Future[void]]()
|
||||
|
||||
if s.pubSub.isSome:
|
||||
futs &= s.pubSub.get().stop()
|
||||
await s.pubSub.get().stop()
|
||||
|
||||
futs &= toSeq(s.connections.values).mapIt(s.cleanupConn(it))
|
||||
futs &= s.transports.mapIt(it.close())
|
||||
checkFutures(
|
||||
await allFinished(
|
||||
toSeq(s.connections.values).mapIt(s.cleanupConn(it))))
|
||||
|
||||
futs = await allFinished(futs)
|
||||
checkFutures(futs)
|
||||
checkFutures(
|
||||
await allFinished(
|
||||
s.transports.mapIt(it.close())))
|
||||
|
||||
trace "switch stopped"
|
||||
|
||||
|
|
|
@ -71,8 +71,9 @@ proc connHandler*(t: TcpTransport,
|
|||
if not isNil(t.handler):
|
||||
t.handlers &= t.handler(conn)
|
||||
|
||||
t.connections.add(conn)
|
||||
t.cleanups &= t.cleanup(conn)
|
||||
# TODO: store the streamtransport client here
|
||||
t.connections.add(conn)
|
||||
t.cleanups &= t.cleanup(conn)
|
||||
|
||||
result = conn
|
||||
|
||||
|
|
Loading…
Reference in New Issue