Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent PeerSet service to be buffered #1718

Closed
wants to merge 5 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions zebra-network/src/peer_set/set.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::net::SocketAddr;
use std::{
any::type_name,
collections::HashMap,
fmt::Debug,
future::Future,
Expand Down Expand Up @@ -405,6 +406,14 @@ where
Pin<Box<dyn Future<Output = Result<Self::Response, Self::Error>> + Send + 'static>>;

fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
// Using `poll_ready` without `call` fills up `Buffer` reservations, causing hangs.
// See #1593 for details.
assert!(
!type_name::<D::Service>().contains("Buffer"),
"Clients must not use tower::Buffer, because PeerSet uses `poll_ready`
multiple times before each `call`, which causes buffer hangs"
);

self.poll_background_errors(cx)?;
// Process peer discovery updates.
let _ = self.poll_discover(cx)?;
Expand Down