Skip to content

Commit

Permalink
Avoid adding ready services for outdated peers
Browse files Browse the repository at this point in the history
If a service becomes ready but it's for a connection to an outdated
peer, drop it.
  • Loading branch information
jvff committed Dec 2, 2021
1 parent 22485bb commit 32f0417
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions zebra-network/src/peer_set/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,8 @@ where

/// Check busy peer services for request completion or errors.
///
/// Move newly ready services to the ready list, and drop failed services.
/// Move newly ready services to the ready list if they are for peers with supported protocol
/// versions, otherwise they are dropped. Also drop failed services.
fn poll_unready(&mut self, cx: &mut Context<'_>) {
loop {
match Pin::new(&mut self.unready_services).poll_next(cx) {
Expand All @@ -364,7 +365,10 @@ where
trace!(?key, "service became ready");
let cancel = self.cancel_handles.remove(&key);
assert!(cancel.is_some(), "missing cancel handle");
self.ready_services.insert(key, svc);

if svc.version() >= self.minimum_peer_version.current() {
self.ready_services.insert(key, svc);
}
}

// Unready -> Canceled
Expand Down

0 comments on commit 32f0417

Please sign in to comment.