makes CrdsGossipPush thread-safe (#18581)

This commit is contained in:
behzad nouri
2021-07-13 14:04:25 +00:00
committed by GitHub
parent 12a93a9951
commit 90f8cf0920
4 changed files with 248 additions and 163 deletions

View File

@@ -322,9 +322,9 @@ pub fn cluster_info_scale() {
.filter(|v| v.message.account_keys == tx.message.account_keys)
.count();
let gossip = node.gossip.read().unwrap();
num_old += gossip.push.num_old;
num_push_total += gossip.push.num_total;
num_pushes += gossip.push.num_pushes;
num_old += gossip.push.num_old.load(Ordering::Relaxed);
num_push_total += gossip.push.num_total.load(Ordering::Relaxed);
num_pushes += gossip.push.num_pushes.load(Ordering::Relaxed);
num_pulls += gossip.pull.num_pulls.load(Ordering::Relaxed);
if has_tx == 0 {
not_done += 1;
@@ -348,10 +348,10 @@ pub fn cluster_info_scale() {
);
sleep(Duration::from_millis(200));
for (node, _, _) in nodes.iter() {
let mut gossip = node.gossip.write().unwrap();
gossip.push.num_old = 0;
gossip.push.num_total = 0;
gossip.push.num_pushes = 0;
let gossip = node.gossip.read().unwrap();
gossip.push.num_old.store(0, Ordering::Relaxed);
gossip.push.num_total.store(0, Ordering::Relaxed);
gossip.push.num_pushes.store(0, Ordering::Relaxed);
gossip.pull.num_pulls.store(0, Ordering::Relaxed);
}
}