Don't modify iterables while iterating them (#219)

* don't modify iterables while iterating

* assert handlers to properly close connections
This commit is contained in:
Dmitriy Ryajov 2020-06-15 12:30:09 -06:00 committed by GitHub
parent 9cd47fe816
commit 7cb6c81159
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 1 deletions

View File

@ -118,6 +118,7 @@ method handle*(m: Mplex) {.async, gcsafe.} =
# doAssert(stream.closed, "connection not closed by handler!")
except CatchableError as exc:
trace "exception in stream handler", exc = exc.msg
doAssert(stream.closed, "stream not closed by protocol handler")
finally:
m.conns.keepItIf(it != stream)
m.handlerFuts.keepItIf(it != fut)

View File

@ -215,7 +215,7 @@ proc heartbeat(g: GossipSub) {.async.} =
await g.heartbeatLock.acquire()
trace "running heartbeat"
for t in g.topics.keys:
for t in toSeq(g.topics.keys):
await g.rebalanceMesh(t)
await g.dropFanoutPeers()