acquire client report under lock in informant (#6072)

This commit is contained in:
Robert Habermeier 2017-07-16 17:43:43 +02:00 committed by Arkadiy Paronyan
parent 30f2057bdf
commit fec4ccbbb8

View File

@ -254,21 +254,24 @@ impl<T: InformantData> Informant<T> {
return; 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 { let Report {
importing, importing,
chain_info, chain_info,
client_report,
queue_info, queue_info,
cache_sizes, cache_sizes,
sync_info, sync_info,
} = self.target.report(); ..
} = full_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
};
let rpc_stats = self.rpc_stats.as_ref(); let rpc_stats = self.rpc_stats.as_ref();
@ -284,8 +287,6 @@ impl<T: InformantData> Informant<T> {
return; return;
} }
*self.last_tick.write() = Instant::now();
let paint = |c: Style, t: String| match self.with_color && stdout_isatty() { let paint = |c: Style, t: String| match self.with_color && stdout_isatty() {
true => format!("{}", c.paint(t)), true => format!("{}", c.paint(t)),
false => t, false => t,