Explorar o código

Do not delay if the last retry fails.

Jing Yang %!s(int64=5) %!d(string=hai) anos
pai
achega
b838091bd6
Modificáronse 1 ficheiros con 3 adicións e 1 borrados
  1. 3 1
      src/utils.rs

+ 3 - 1
src/utils.rs

@@ -10,10 +10,12 @@ where
     Func: FnMut(usize) -> Fut,
 {
     for i in 0..max_retry {
+        if i != 0 {
+            tokio::time::delay_for(Duration::from_millis((1 << i) * 10)).await;
+        }
         if let Ok(reply) = task_gen(i).await {
             return Ok(reply);
         }
-        tokio::time::delay_for(Duration::from_millis((1 << i) * 10)).await;
     }
     Err(std::io::Error::new(
         std::io::ErrorKind::TimedOut,