From 4055eb8889dcc5b350d6ca4d41845be77f84b0a0 Mon Sep 17 00:00:00 2001 From: Henry de Valence Date: Tue, 22 Oct 2019 14:42:46 -0700 Subject: [PATCH] bugfix: ensure the PeerServer always calls fail_with before exit This caused a panic in the PeerSet when remote peers disconnected from us. --- zebra-network/src/peer/server.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/zebra-network/src/peer/server.rs b/zebra-network/src/peer/server.rs index b54755b4..39425838 100644 --- a/zebra-network/src/peer/server.rs +++ b/zebra-network/src/peer/server.rs @@ -83,8 +83,7 @@ where trace!("awaiting client request or peer message"); match future::select(peer_rx.next(), self.client_rx.next()).await { Either::Left((None, _)) => { - info!("peer stream closed, shutting down"); - return; + self.fail_with(PeerError::ConnectionClosed); } // XXX switch back to hard failure when we parse all message types //Either::Left((Some(Err(e)), _)) => self.fail_with(e.into()), @@ -93,8 +92,7 @@ where self.handle_message_as_request(msg).await } Either::Right((None, _)) => { - info!("client stream closed, shutting down"); - return; + self.fail_with(PeerError::DeadPeerClient); } Either::Right((Some(req), _)) => self.handle_client_request(req).await, } @@ -158,7 +156,7 @@ where /// Marks the peer as having failed with error `e`. fn fail_with(&mut self, e: PeerError) { - trace!(%e, "failing peer service with error"); + debug!(%e, "failing peer service with error"); // Update the shared error slot let mut guard = self .error_slot