From 02f44cfab62a587dfeada1128767ce479d0299ec Mon Sep 17 00:00:00 2001 From: soruh Date: Fri, 9 Jun 2023 15:43:01 +0200 Subject: [PATCH] continue if accept fails --- src/main.rs | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/main.rs b/src/main.rs index eac4b66..b5ea11f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -350,13 +350,22 @@ async fn tokio_main(config: Arc) -> eyre::Result<()> { "centralex server listening" ); - while let Ok((stream, addr)) = listener.accept().await { - info!(%addr, "new connection"); + loop { + let connection = listener.accept().await; - spawn( - &format!("connection to {addr}"), - connection_handler(stream, addr, config.clone(), port_handler.clone()), - ); + match connection { + Ok((stream, addr)) => { + info!(%addr, "new connection"); + + spawn( + &format!("connection to {addr}"), + connection_handler(stream, addr, config.clone(), port_handler.clone()), + ); + } + Err(err) => { + error!(%err, "failed to accept connection"); + } + } } Ok(())