Add check if message loop is finished during connection stage

This commit is contained in:
kdeme 2019-06-21 11:14:00 +02:00 committed by zah
parent d535bb1ade
commit 0a5d6118c2
1 changed files with 7 additions and 0 deletions

View File

@ -1291,6 +1291,13 @@ proc postHelloSteps(peer: Peer, h: devp2p.hello) {.async.} =
#
await all(subProtocolsHandshakes)
# This is needed as a peer might have already disconnected. In this case
# we need to raise so that rlpxConnect/rlpxAccept fails.
# Disconnect is done only to run the disconnect handlers. TODO: improve this
# also TODO: Should we discern the type of error?
if messageProcessingLoop.finished:
await peer.disconnectAndRaise(ClientQuitting,
"messageProcessingLoop ended while connecting")
peer.connectionState = Connected
template `^`(arr): auto =