continue if accept fails

This commit is contained in:
soruh 2023-06-09 15:43:01 +02:00
parent 0eed949a27
commit 02f44cfab6

View File

@ -350,13 +350,22 @@ async fn tokio_main(config: Arc<Config>) -> eyre::Result<()> {
"centralex server listening" "centralex server listening"
); );
while let Ok((stream, addr)) = listener.accept().await { loop {
info!(%addr, "new connection"); let connection = listener.accept().await;
spawn( match connection {
&format!("connection to {addr}"), Ok((stream, addr)) => {
connection_handler(stream, addr, config.clone(), port_handler.clone()), 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(()) Ok(())