From 91be3a4fc3f9d2be90ae8248fecffc14c2ae7359 Mon Sep 17 00:00:00 2001 From: Robert Habermeier Date: Sun, 16 Jul 2017 17:45:28 +0200 Subject: [PATCH] acquire client report under lock in informant (#6071) --- parity/informant.rs | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/parity/informant.rs b/parity/informant.rs index 7e1e4ed4d..4c3b4aca2 100644 --- a/parity/informant.rs +++ b/parity/informant.rs @@ -254,21 +254,24 @@ impl Informant { return; } + *self.last_tick.write() = Instant::now(); + + let (client_report, full_report) = { + let mut last_report = self.last_report.lock(); + let full_report = self.target.report(); + let diffed = full_report.client_report.clone() - &*last_report; + *last_report = full_report.client_report.clone(); + (diffed, full_report) + }; + let Report { importing, chain_info, - client_report, queue_info, cache_sizes, sync_info, - } = self.target.report(); - - let client_report = { - let mut last_report = self.last_report.lock(); - let diffed = client_report.clone() - &*last_report; - *last_report = client_report.clone(); - diffed - }; + .. + } = full_report; let rpc_stats = self.rpc_stats.as_ref(); @@ -284,8 +287,6 @@ impl Informant { return; } - *self.last_tick.write() = Instant::now(); - let paint = |c: Style, t: String| match self.with_color && stdout_isatty() { true => format!("{}", c.paint(t)), false => t,