Skip to content

Commit

Permalink
fix: Don't use connection pool in Endpoint::is_reachable
Browse files Browse the repository at this point in the history
The point of this function is to test if a given address can be
connected to. If we use the connection pool, we may use a connection
that they established, giving us a false positive.
  • Loading branch information
Chris Connelly committed Aug 26, 2021
1 parent 63a09ea commit 4d46a11
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,12 @@ impl<I: ConnId> Endpoint<I> {
/// can be reached.
pub async fn is_reachable(&self, peer_addr: &SocketAddr) -> Result<(), RpcError> {
trace!("Checking is reachable");
let connection = self.get_or_connect_to(peer_addr).await?;
let (mut send_stream, mut recv_stream) = connection.open_bi(0).await?;

// avoid the connection pool
let quinn::NewConnection { connection, .. } = self.new_connection(peer_addr).await?;
let (send_stream, recv_stream) = connection.open_bi().await?;
let mut send_stream = SendStream::new(send_stream);
let mut recv_stream = RecvStream::new(recv_stream);

send_stream.send(WireMsg::EndpointEchoReq).await?;

Expand Down

0 comments on commit 4d46a11

Please sign in to comment.