From 77ac4bc5c2cba64d1d0e4cfc99aff5cded2a5c01 Mon Sep 17 00:00:00 2001 From: Arun Kulshreshtha Date: Mon, 29 Apr 2019 13:14:47 -0700 Subject: [PATCH] edenapi: move active transfer check into loop body Summary: Due to the structure of this loop, we were unnecessarily blocking and polling when all curl transfers were already complete. To fix this, move the loop condition check to the middle of the loop. Reviewed By: quark-zju Differential Revision: D15124823 fbshipit-source-id: 92b7eee83cbfd62d590c21893f3235e1ca04fcec --- lib/edenapi/src/curl/driver.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/edenapi/src/curl/driver.rs b/lib/edenapi/src/curl/driver.rs index bf1e72ad9b..6e9ffd4e4f 100644 --- a/lib/edenapi/src/curl/driver.rs +++ b/lib/edenapi/src/curl/driver.rs @@ -90,7 +90,7 @@ impl MultiDriver { let mut failed = Vec::new(); let mut i = 0; - while in_progress > 0 { + loop { log::trace!( "Iteration {}: {}/{} transfers complete", i, @@ -126,6 +126,11 @@ impl MultiDriver { break; } + if in_progress == 0 { + log::debug!("All transfers finished successfully."); + break; + } + let timeout = self.multi.get_timeout()?.unwrap_or(DEFAULT_TIMEOUT); log::trace!("Waiting for I/O with timeout: {:?}", &timeout);