diff options
author | Christian Helbling | 2019-11-21 14:53:30 +0100 |
---|---|---|
committer | Christian Helbling | 2019-11-21 14:53:30 +0100 |
commit | a396d1753bc91b69cdda777f7382fcf72eac4ada (patch) | |
tree | b2d4da337811507ba3c53d5330e214c87c89e9a2 /it_url.class | |
parent | f433e2a680327252d7c6b26884ccd12bbaf45d28 (diff) | |
download | itools-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
Diffstat (limited to 'it_url.class')
-rw-r--r-- | it_url.class | 17 |
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)); |