Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Fix a deadlock #9952

Merged
merged 3 commits into from
Nov 25, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ethcore/src/blockchain/blockchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1530,8 +1530,8 @@ impl BlockChain {
let genesis_hash = self.genesis_hash();

// ensure data consistencly by locking everything first
let best_block = self.best_block.read();
let best_ancient_block = self.best_ancient_block.read();
let best_block = self.best_block.read();
ngotchac marked this conversation as resolved.
Show resolved Hide resolved
BlockChainInfo {
total_difficulty: best_block.total_difficulty,
pending_total_difficulty: best_block.total_difficulty,
Expand Down
12 changes: 5 additions & 7 deletions parity/informant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,16 +256,13 @@ impl<T: InformantData> Informant<T> {
}

pub fn tick(&self) {
let elapsed = self.last_tick.read().elapsed();
if elapsed < Duration::from_secs(5) {
return;
}
let now = Instant::now();
let elapsed = now.duration_since(*self.last_tick.read());

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)
};

Expand All @@ -289,7 +286,8 @@ impl<T: InformantData> Informant<T> {
return;
}

*self.last_tick.write() = Instant::now();
*self.last_tick.write() = now;
*self.last_report.lock() = full_report.client_report.clone();
ngotchac marked this conversation as resolved.
Show resolved Hide resolved

let paint = |c: Style, t: String| match self.with_color && atty::is(atty::Stream::Stdout) {
true => format!("{}", c.paint(t)),
Expand All @@ -306,7 +304,7 @@ impl<T: InformantData> Informant<T> {
format!("{} blk/s {} tx/s {} Mgas/s",
paint(Yellow.bold(), format!("{:7.2}", (client_report.blocks_imported * 1000) as f64 / elapsed.as_milliseconds() as f64)),
paint(Yellow.bold(), format!("{:6.1}", (client_report.transactions_applied * 1000) as f64 / elapsed.as_milliseconds() as f64)),
paint(Yellow.bold(), format!("{:4}", (client_report.gas_processed / (elapsed.as_milliseconds() * 1000)).low_u64()))
paint(Yellow.bold(), format!("{:6.1}", (client_report.gas_processed / 1000).low_u64() as f64 / elapsed.as_milliseconds() as f64))
)
} else {
format!("{} hdr/s",
Expand Down