fixed coord timeouts

This commit is contained in:
Valmo Trindade
2026-06-29 10:32:55 +00:00
parent 189b496ad9
commit d83acce887
2 changed files with 113 additions and 23 deletions
+12 -3
View File
@@ -113,7 +113,7 @@ pub async fn run_coordinator(
}
maybe_finished = handlers.join_next(), if !handlers.is_empty() => {
if let Some(join_result) = maybe_finished {
join_result??;
log_worker_result(join_result);
}
}
}
@@ -124,7 +124,7 @@ pub async fn run_coordinator(
}
while let Some(join_result) = handlers.join_next().await {
join_result??;
log_worker_result(join_result);
}
let duration = start.elapsed().as_secs_f64();
@@ -175,6 +175,14 @@ pub async fn run_coordinator(
Ok(())
}
fn log_worker_result(result: std::result::Result<Result<()>, tokio::task::JoinError>) {
match result {
Ok(Ok(())) => {}
Ok(Err(err)) => eprintln!("worker handler ended with error: {err:#}"),
Err(err) => eprintln!("worker task failed: {err}"),
}
}
async fn handle_worker(
stream: TcpStream,
peer: std::net::SocketAddr,
@@ -194,7 +202,8 @@ async fn handle_worker(
let worker_name = match lines.next_line().await? {
Some(line) if line.starts_with("HELLO ") => line[6..].trim().to_string(),
Some(line) => {
return Err(anyhow!("unexpected worker handshake from {peer}: {line}"));
eprintln!("rejected non-worker connection from {peer}: {line}");
return Ok(());
}
None => return Ok(()),
};