From 2c6049b1266a7739f4dca86da4e8c65b75797195 Mon Sep 17 00:00:00 2001 From: Kim De Mey Date: Fri, 19 Jan 2024 12:29:11 +0100 Subject: [PATCH] Fix a future .callback usage in rlpx (#666) --- eth/p2p/rlpx.nim | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/eth/p2p/rlpx.nim b/eth/p2p/rlpx.nim index a0f1ced..488fc50 100644 --- a/eth/p2p/rlpx.nim +++ b/eth/p2p/rlpx.nim @@ -1175,12 +1175,14 @@ proc postHelloSteps(peer: Peer, h: DevP2P.hello) {.async.} = # var messageProcessingLoop = peer.dispatchMessages() - messageProcessingLoop.callback = proc(p: pointer) {.gcsafe.} = + let cb = proc(p: pointer) {.gcsafe.} = if messageProcessingLoop.failed: debug "Ending dispatchMessages loop", peer, err = messageProcessingLoop.error.msg traceAsyncErrors peer.disconnect(ClientQuitting) + messageProcessingLoop.addCallback(cb) + # The handshake may involve multiple async steps, so we wait # here for all of them to finish. #