summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Helbling2019-11-21 14:53:30 +0100
committerChristian Helbling2019-11-21 14:53:30 +0100
commita396d1753bc91b69cdda777f7382fcf72eac4ada (patch)
treeb2d4da337811507ba3c53d5330e214c87c89e9a2
parentf433e2a680327252d7c6b26884ccd12bbaf45d28 (diff)
downloaditools-a396d1753bc91b69cdda777f7382fcf72eac4ada.tar.gz
itools-a396d1753bc91b69cdda777f7382fcf72eac4ada.tar.bz2
itools-a396d1753bc91b69cdda777f7382fcf72eac4ada.zip
get_muti: only call handler on curl success, give curl handle to handler so handler can use functions like curl_getinfo to extract data like the http error code
-rw-r--r--it_url.class17
1 files changed, 10 insertions, 7 deletions
diff --git a/it_url.class b/it_url.class
index 626311c..ef17e53 100644
--- a/it_url.class
+++ b/it_url.class
@@ -378,19 +378,22 @@ static function get_multi($p=null)
$key = $keys[$info['handle']];
$content = curl_multi_getcontent($info['handle']);
- $closehandle($key);
-
EDC('reqtimings', $key, $info['result'], (gettimeofday(true) - $start) * 1000);
if ($info['result'] == CURLE_OK) {
if (!$p['noresults'])
$results_unordered[$key] = $content;
- } else if($retries[$key]++ < $p['retries'])
+
+ if (($handler = $urls[$key]['handler']))
+ $abort = $handler($info['handle'], $content);
+
+ $closehandle($key);
+ } else if($retries[$key]++ < $p['retries']) {
+ $closehandle($key); # closehandle must be called before addhandle as we use the same key
$addhandle($key);
- else
+ } else {
$results_unordered[$key] = false;
-
- if (($handler = $urls[$key]['handler']))
- $abort = $handler($info['result'], $content);
+ $closehandle($key);
+ }
if (!$abort && count($handles) < $parallel && $tofetch)
$addhandle(array_shift($tofetch));