From ba69c1ff291c1daface52bb01bf6307ffb6c822d Mon Sep 17 00:00:00 2001 From: Kim De Mey Date: Thu, 6 Oct 2022 13:34:35 +0200 Subject: [PATCH] Quickfix for a potential double future completion in rlpx (#538) --- eth/p2p/rlpx.nim | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/eth/p2p/rlpx.nim b/eth/p2p/rlpx.nim index a69d06c..fc3b916 100644 --- a/eth/p2p/rlpx.nim +++ b/eth/p2p/rlpx.nim @@ -148,8 +148,10 @@ proc requestResolver[MsgType](msg: pointer, future: FutureBase) {.gcsafe.} = proc linkSendFailureToReqFuture[S, R](sendFut: Future[S], resFut: Future[R]) = sendFut.addCallback() do (arg: pointer): - if not sendFut.error.isNil: - resFut.fail(sendFut.error) + # Avoiding potentially double future completions + if not resFut.finished: + if sendFut.failed: + resFut.fail(sendFut.error) proc messagePrinter[MsgType](msg: pointer): string {.gcsafe.} = result = ""