From 09c8c8946299a7b9734014723558b3bc63ca54bc Mon Sep 17 00:00:00 2001 From: teor Date: Fri, 29 Jan 2021 13:06:24 +1000 Subject: [PATCH] Make sure FailedInit never escapes Inbound::poll_ready --- zebrad/src/components/inbound.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/zebrad/src/components/inbound.rs b/zebrad/src/components/inbound.rs index c6820bd0..24bafee9 100644 --- a/zebrad/src/components/inbound.rs +++ b/zebrad/src/components/inbound.rs @@ -183,8 +183,8 @@ impl Service for Inbound { Setup::FailedRecv { error } } }, - // Make sure we left the network setup in a valid state - Setup::FailedInit => unreachable!("incomplete Inbound initialization"), + // Make sure previous network setups were left in a valid state + Setup::FailedInit => unreachable!("incomplete previous Inbound initialization"), // If network setup failed, report service failure Setup::FailedRecv { error } => { result = Err(error.clone().into()); @@ -203,6 +203,11 @@ impl Service for Inbound { } }; + // Make sure we're leaving the network setup in a valid state + if matches!(self.network_setup, Setup::FailedInit) { + unreachable!("incomplete Inbound initialization after poll_ready state handling"); + } + // TODO: // * do we want to propagate backpressure from the download queue or its outbound network? // currently, the download queue waits for the outbound network in the download future,