Skip to content

Commit

Permalink
verifies packets outside the lock
Browse files Browse the repository at this point in the history
  • Loading branch information
behzadnouri committed Oct 21, 2020
1 parent 34af49b commit bae6195
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions core/src/cluster_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2139,19 +2139,25 @@ impl ClusterInfo {
where
I: IntoIterator<Item = (Pong, SocketAddr)>,
{
let mut pongs = pongs.into_iter().peekable();
if pongs.peek().is_some() {
let mut verify_failed = 0;
let mut ping_cache = self.ping_cache.write().unwrap();
for (pong, addr) in pongs {
let mut verify_failed = 0;
let pongs: Vec<_> = pongs
.into_iter()
.filter(|(pong, _)| {
if pong.verify() {
ping_cache.add(&pong, addr, now);
true
} else {
verify_failed += 1;
false
}
}
if verify_failed != 0 {
inc_new_counter_info!("cluster_info-gossip_pong_msg_verify_fail", verify_failed);
})
.collect();
if verify_failed != 0 {
inc_new_counter_info!("cluster_info-gossip_pong_msg_verify_fail", verify_failed);
}
if !pongs.is_empty() {
let mut ping_cache = self.ping_cache.write().unwrap();
for (pong, addr) in pongs {
ping_cache.add(&pong, addr, now);
}
}
}
Expand Down

0 comments on commit bae6195

Please sign in to comment.