From 97cc6b69d05b43cea9e66af01fca6e11148cb92a Mon Sep 17 00:00:00 2001 From: Nathan Gass Date: Mon, 19 Nov 2012 18:55:52 +0000 Subject: make sure results are returned in the same order as input urls array --- it_url.class | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'it_url.class') diff --git a/it_url.class b/it_url.class index 2739ba4..6fe3183 100644 --- a/it_url.class +++ b/it_url.class @@ -403,7 +403,6 @@ function get_multi($p=null) $mrc = curl_multi_exec($mh, $active); } while ($mrc == CURLM_CALL_MULTI_PERFORM); - $results = array(); $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) { @@ -419,9 +418,9 @@ function get_multi($p=null) $key = $keys[$info['handle']]; EDC('reqtimings', $key, $info['result'], (microtime(true) - $start) * 1000); if ($info['result'] == CURLE_OK) - $results[$key] = curl_multi_getcontent($info['handle']); + $results_unordered[$key] = curl_multi_getcontent($info['handle']); else - $results[$key] = false; + $results_unordered[$key] = false; if (($handler = $urls[$keys[$info['handle']]]['handler'])) $abort = $handler($info['result'], $results[$key]); } @@ -431,9 +430,11 @@ function get_multi($p=null) $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 } + $results = array(); foreach ($handles as $key => $handle) { curl_multi_remove_handle($mh, $handle); curl_close($handle); + $results[$key] = $results_unordered[$key]; } curl_multi_close($mh); return $results; -- cgit v1.2.3