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"
);
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(())