Push down cluster_info lock (#9594)

* Push down cluster_info lock

* Rework budget decrement

Co-authored-by: Carl <carl@solana.com>
This commit is contained in:
carllin
2020-04-21 12:54:45 -07:00
committed by GitHub
parent ad186b8652
commit bab3502260
32 changed files with 679 additions and 671 deletions

View File

@ -6,7 +6,7 @@ use std::{
sync::{
atomic::{AtomicBool, Ordering},
mpsc::RecvTimeoutError,
Arc, RwLock,
Arc,
},
thread::{self, Builder, JoinHandle},
time::Duration,
@ -21,7 +21,7 @@ impl SnapshotPackagerService {
snapshot_package_receiver: AccountsPackageReceiver,
starting_snapshot_hash: Option<(Slot, Hash)>,
exit: &Arc<AtomicBool>,
cluster_info: &Arc<RwLock<ClusterInfo>>,
cluster_info: &Arc<ClusterInfo>,
blockstore: Option<Arc<Blockstore>>,
) -> Self {
let exit = exit.clone();
@ -34,10 +34,7 @@ impl SnapshotPackagerService {
if let Some(starting_snapshot_hash) = starting_snapshot_hash {
hashes.push(starting_snapshot_hash);
}
cluster_info
.write()
.unwrap()
.push_snapshot_hashes(hashes.clone());
cluster_info.push_snapshot_hashes(hashes.clone());
loop {
if exit.load(Ordering::Relaxed) {
break;
@ -60,10 +57,7 @@ impl SnapshotPackagerService {
while hashes.len() > MAX_SNAPSHOT_HASHES {
hashes.remove(0);
}
cluster_info
.write()
.unwrap()
.push_snapshot_hashes(hashes.clone());
cluster_info.push_snapshot_hashes(hashes.clone());
}
if let Some(ref blockstore) = blockstore {
let _ = blockstore.tar_shreds(snapshot_package.root);