From 4d46a11ce601c070f85e46888bd0514942232d51 Mon Sep 17 00:00:00 2001 From: Chris Connelly Date: Thu, 26 Aug 2021 16:29:51 +0100 Subject: [PATCH] fix: Don't use connection pool in `Endpoint::is_reachable` 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. --- src/endpoint.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/endpoint.rs b/src/endpoint.rs index 18cdf1d9..b02cc90b 100644 --- a/src/endpoint.rs +++ b/src/endpoint.rs @@ -349,8 +349,12 @@ impl Endpoint { /// 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?;