Skip to content

Commit

Permalink
runtime: fix possible deadlock in bank
Browse files Browse the repository at this point in the history
  • Loading branch information
BurtonQin committed Jun 9, 2020
1 parent 704d98a commit 839750a
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ use std::{
mem,
ops::RangeInclusive,
path::PathBuf,
ptr,
rc::Rc,
sync::atomic::{AtomicBool, AtomicU64, Ordering},
sync::{Arc, RwLock, RwLockReadGuard},
Expand Down Expand Up @@ -2494,6 +2495,9 @@ impl Bank {
}

pub fn compare_bank(&self, dbank: &Bank) {
if ptr::eq(self, dbank) {
return;
}
assert_eq!(self.slot, dbank.slot);
assert_eq!(self.collector_id, dbank.collector_id);
assert_eq!(self.epoch_schedule, dbank.epoch_schedule);
Expand All @@ -2509,14 +2513,14 @@ impl Bank {
dbank.is_delta.load(Ordering::Relaxed)
);

let st = self.stakes.read().unwrap();
let dst = dbank.stakes.read().unwrap();
assert_eq!(*st, *dst);

let bh = self.hash.read().unwrap();
let dbh = dbank.hash.read().unwrap();
assert_eq!(*bh, *dbh);

let st = self.stakes.read().unwrap();
let dst = dbank.stakes.read().unwrap();
assert_eq!(*st, *dst);

let bhq = self.blockhash_queue.read().unwrap();
let dbhq = dbank.blockhash_queue.read().unwrap();
assert_eq!(*bhq, *dbhq);
Expand Down

0 comments on commit 839750a

Please sign in to comment.