Attempt to fix loop
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Pierre HUBERT 2025-02-25 14:47:01 +01:00
parent c09bc6fe36
commit 6e17c3a6c7

View File

@ -117,7 +117,9 @@ async fn main() -> Result<(), Box<dyn Error>> {
log::info!("Got a new client read {count}");
if count == 0 {
log::warn!("infinite loop");
log::warn!("infinite loop (client)");
drop(client_write);
drop(upstream);
return;
}
@ -135,10 +137,21 @@ async fn main() -> Result<(), Box<dyn Error>> {
}
count = upstream.read(&mut buf_server) => {
let count = match count{ Ok(count) => count,Err(e) => {
log::error!("Failed to read from upstream! {e}");
let count = match count {
Ok(count) => count,
Err(e) => {
log::error!("Failed to read from upstream! {e}");
return;
}
};
if count == 0 {
log::warn!("infinite loop (upstream)");
drop(client_write);
drop(upstream);
return;
}};
}
log::info!("Got a new upstream read {count}");
client_write.write_all(&buf_server[..count]).await.expect("Failed to write to client");
res_file.write_all(&buf_server[..count]).expect("Failed to write to res");