From 145e766db2de4b20b208a9bb2478479b74f855fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Fri, 4 Nov 2016 16:59:42 +0100 Subject: [PATCH] Fixing possible race condition in ethcore_hashContent (#3191) --- rpc/src/v1/impls/ethcore.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/rpc/src/v1/impls/ethcore.rs b/rpc/src/v1/impls/ethcore.rs index 52aecb465..1130b8fb8 100644 --- a/rpc/src/v1/impls/ethcore.rs +++ b/rpc/src/v1/impls/ethcore.rs @@ -302,7 +302,9 @@ impl Ethcore for EthcoreClient where .map(Into::into); // Receive ready and invoke with result. - let ready: Ready = rx.try_recv().expect("When on_done is invoked ready object is always sent."); + let ready: Ready = rx.recv().expect( + "recv() fails when `tx` has been dropped, if this closure is invoked `tx` is not dropped (`res == Ok()`); qed" + ); ready.ready(result); })); @@ -310,7 +312,9 @@ impl Ethcore for EthcoreClient where if let Err(e) = res { ready.ready(Err(errors::from_fetch_error(e))); } else { - tx.send(ready).expect("Rx end is sent to on_done closure."); + tx.send(ready).expect( + "send() fails when `rx` end is dropped, if `res == Ok()`: `rx` is moved to the closure; qed" + ); } } }