From 8b65a2b2426fd04d46c943c76af40347a611bcee Mon Sep 17 00:00:00 2001 From: Urban Müller Date: Tue, 21 Apr 2020 14:45:33 +0200 Subject: support retrysleep in ::get_multi --- it_url.class | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/it_url.class b/it_url.class index 5e2b681..765a504 100644 --- a/it_url.class +++ b/it_url.class @@ -409,8 +409,7 @@ static function get_multi($p=null) $closehandle($key); } else if($retries[$key]++ < $p['retries']) { $closehandle($key); # closehandle must be called before addhandle as we use the same key - $addhandle($key, $urls[$key]); - $mrc = CURLM_CALL_MULTI_PERFORM; # force continue if this was last handle + $sleepuntils[$key] = microtime(true) + $p['retrysleep']; } else { $results_unordered[$key] = false; unset($urls[$key]); @@ -424,6 +423,16 @@ static function get_multi($p=null) } } } while ($mrc == CURLM_CALL_MULTI_PERFORM); + + foreach ((array)$sleepuntils as $key => $time) { + if (microtime(true) >= $time) { + $addhandle($key, $urls[$key]); + unset($sleepuntils[$key]); + } + $active = 1; + } + usleep($sleepuntils ? 100000 : 0); + $timeout = 0.1; # Longer delay to avoid busy loop but shorter than default of 1s in case we stil hit cURL 7.25.0 problem } -- cgit v1.2.3