This commit is contained in:
2026-09-17 16:27:34 +02:00
parent a7cd4244b2
commit 775e3d3b8a
5 changed files with 31 additions and 32 deletions
+9 -10
View File
@@ -645,7 +645,8 @@ async fn fetch_index_bytes(url: &str) -> Result<Vec<u8>, String> {
Err(e) => {
last_error = e.to_string();
log::debug!("fetch of '{url}' failed (attempt {attempt}/{ATTEMPTS}): {last_error}");
tokio::time::sleep(std::time::Duration::from_millis(300 * u64::from(attempt))).await;
tokio::time::sleep(std::time::Duration::from_millis(300 * u64::from(attempt)))
.await;
}
Ok(response) => {
if !response.status().is_success() {
@@ -659,9 +660,9 @@ async fn fetch_index_bytes(url: &str) -> Result<Vec<u8>, String> {
log::debug!(
"empty body for '{url}' (attempt {attempt}/{ATTEMPTS}), retrying"
);
tokio::time::sleep(
std::time::Duration::from_millis(300 * u64::from(attempt)),
)
tokio::time::sleep(std::time::Duration::from_millis(
300 * u64::from(attempt),
))
.await;
}
Ok(bytes) => return Ok(bytes.to_vec()),
@@ -671,9 +672,9 @@ async fn fetch_index_bytes(url: &str) -> Result<Vec<u8>, String> {
log::debug!(
"reading the body of '{url}' failed (attempt {attempt}/{ATTEMPTS}): {last_error}"
);
tokio::time::sleep(
std::time::Duration::from_millis(300 * u64::from(attempt)),
)
tokio::time::sleep(std::time::Duration::from_millis(
300 * u64::from(attempt),
))
.await;
}
}
@@ -952,10 +953,8 @@ mod tests {
let listener = std::net::TcpListener::bind("127.0.0.1:0").unwrap();
let addr = listener.local_addr().unwrap();
std::thread::spawn(move || {
let mut served = 0usize;
for stream in listener.incoming().flatten() {
for (served, stream) in listener.incoming().flatten().enumerate() {
let index = served.min(responses.len() - 1);
served += 1;
let mut stream = stream;
// Drain the request first: closing with unread inbound data
// would send a TCP RST and destroy the response in flight