From d9fc5497ada455c242930a5c8d140fda98c40da4 Mon Sep 17 00:00:00 2001 From: Scott Dutton Date: Fri, 9 Jan 2015 12:21:20 +0000 Subject: [PATCH] Adjust the blocking Make sure that blocking waiting for the download does not effect starting a new download off. --- parallelcurl.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/parallelcurl.php b/parallelcurl.php index 28fb508..dff78c7 100755 --- a/parallelcurl.php +++ b/parallelcurl.php @@ -121,7 +121,8 @@ private function checkForCompletedRequests() { } while ($mrc == CURLM_CALL_MULTI_PERFORM); while ($active && $mrc == CURLM_OK) { - if (curl_multi_select($this->multi_handle) != -1) { + //just check if there is anything new, dont wait + if (curl_multi_select($this->multi_handle, 0.01) >0) { do { $mrc = curl_multi_exec($this->multi_handle, $active); } while ($mrc == CURLM_CALL_MULTI_PERFORM); @@ -165,7 +166,7 @@ private function waitForOutstandingRequestsToDropBelow($max) if (count($this->outstanding_requests)<$max) break; - usleep(10000); + curl_multi_select($this->multi_handle); } }