summaryrefslogtreecommitdiff
path: root/it_url.class
diff options
context:
space:
mode:
authorNathan Gass2012-12-03 14:56:03 +0000
committerNathan Gass2012-12-03 14:56:03 +0000
commitf6161a1670a419d14f4000863cabeaa26ee1638a (patch)
tree5a6480ba71013f273a03da0d41b12800b0ead2b9 /it_url.class
parentecea76684314768e352deffbe9ffadd679cbcba7 (diff)
downloaditools-f6161a1670a419d14f4000863cabeaa26ee1638a.tar.gz
itools-f6161a1670a419d14f4000863cabeaa26ee1638a.tar.bz2
itools-f6161a1670a419d14f4000863cabeaa26ee1638a.zip
curl_multi_select can return -1 without select when polling is necessary (see curl_multi_fdset doku)
Diffstat (limited to 'it_url.class')
-rw-r--r--it_url.class37
1 files changed, 18 insertions, 19 deletions
diff --git a/it_url.class b/it_url.class
index d8e5afb..81729c6 100644
--- a/it_url.class
+++ b/it_url.class
@@ -404,29 +404,28 @@ function get_multi($p=null)
} while ($mrc == CURLM_CALL_MULTI_PERFORM);
$timeout = 0.001; # Very short timeout to work around problem with first select call on cURL 7.25.0
- while (!$abort && $active && $mrc == CURLM_OK)
+ while (!$abort && $active && $mrc == CURLM_OK)
{
- if (curl_multi_select($mh, $timeout) != -1)
- {
- do {
- $mrc = curl_multi_exec($mh, $active);
+ if (curl_multi_select($mh, $timeout) == -1)
+ usleep($timeout * 1000000);
+ do {
+ $mrc = curl_multi_exec($mh, $active);
- while (($info = curl_multi_info_read($mh)) !== false)
+ while (($info = curl_multi_info_read($mh)) !== false)
+ {
+ if ($info['msg'] == CURLMSG_DONE)
{
- if ($info['msg'] == CURLMSG_DONE)
- {
- $key = $keys[$info['handle']];
- EDC('reqtimings', $key, $info['result'], (microtime(true) - $start) * 1000);
- if ($info['result'] == CURLE_OK)
- $results_unordered[$key] = curl_multi_getcontent($info['handle']);
- else
- $results_unordered[$key] = false;
- if (($handler = $urls[$keys[$info['handle']]]['handler']))
- $abort = $handler($info['result'], $results_unordered[$key]);
- }
+ $key = $keys[$info['handle']];
+ EDC('reqtimings', $key, $info['result'], (microtime(true) - $start) * 1000);
+ if ($info['result'] == CURLE_OK)
+ $results_unordered[$key] = curl_multi_getcontent($info['handle']);
+ else
+ $results_unordered[$key] = false;
+ if (($handler = $urls[$keys[$info['handle']]]['handler']))
+ $abort = $handler($info['result'], $results_unordered[$key]);
}
- } while ($mrc == CURLM_CALL_MULTI_PERFORM);
- }
+ }
+ } while ($mrc == CURLM_CALL_MULTI_PERFORM);
$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
}