fix: Avoid stopping accepting new connection on error

This commit is contained in:
Σrebe - Romain GERARD 2024-03-27 08:25:46 +01:00
parent 450d76aaed
commit 94d9a14c81
No known key found for this signature in database
GPG key ID: 7A42B4B97E0332F4
2 changed files with 10 additions and 2 deletions

View file

@ -63,7 +63,15 @@ where
W: AsyncWrite + Send + 'static, W: AsyncWrite + Send + 'static,
{ {
pin_mut!(incoming_cnx); pin_mut!(incoming_cnx);
while let Some(Ok((cnx_stream, remote_addr))) = incoming_cnx.next().await { while let Some(cnx) = incoming_cnx.next().await {
let (cnx_stream, remote_addr) = match cnx {
Ok((cnx_stream, remote_addr)) => (cnx_stream, remote_addr),
Err(err) => {
error!("Error accepting connection: {:?}", err);
continue;
}
};
let request_id = Uuid::now_v7(); let request_id = Uuid::now_v7();
let span = span!( let span = span!(
Level::INFO, Level::INFO,

View file

@ -205,7 +205,7 @@ where
None => break, None => break,
Some(Err(err)) => { Some(Err(err)) => {
warn!("Error while listening for incoming connections {err:?}"); warn!("Error while listening for incoming connections {err:?}");
break; continue;
} }
Some(Ok(cnx)) => { Some(Ok(cnx)) => {
if tx.send_timeout(cnx, Duration::from_secs(30)).await.is_err() { if tx.send_timeout(cnx, Duration::from_secs(30)).await.is_err() {