Doc #63842 [Nab]: Infinite loop in example code
| From: | dean at ovts dot com dot au | Date: | Wed, 16 Jan 2013 19:21:35 +0000 |
| Subject: | Doc #63842 [Nab]: Infinite loop in example code | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-9433@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=63842&edit=1
ID: 63842
User updated by: dean at ovts dot com dot au
Reported by: dean at ovts dot com dot au
Summary: Infinite loop in example code
Status: Not a bug
Type: Documentation Problem
Package: Documentation problem
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
Googleguy, under bug #61141, several people report that they do indeed get an infinite loop because
curl_multi_select returns -1 indefinitely...
Previous Comments:
------------------------------------------------------------------------
[2013-01-16 19:14:19] dean at ovts dot com dot au
If the loop is entered and curl_multi_select then returns -1, the variables determining the loop
condition remain unchanged, so curl_multi_select is simply called repeatedly until such time as it
returns something other than -1.
Googleguy, I don't quite understand what you were saying: Is it that eventually
curl_multi_select is *GUARANTEED* to return something other than -1? *IF* that's true then
there's no infinite loop.
However, it's still very unclear exectly how/why this code is supposed to work. I'd like
to see an explanation/clarification in the docs of the return values from curl_multi_exec and
curl_multi_select, and of the $active flag. What exactly does a -1 returned from curl_multi_select
imply? And (again) what would it mean if $active were true, but the return value from
curl_multi_exec wasn't CURLM_OK?
At the moment, without any such explanation in the docs, the example code is like an opaque magic
formula for how curl_multi_exec should be used. It's difficult to trust it, when there are
many "alternative versions" posted on the internet, and some on other php docs pages too!
------------------------------------------------------------------------
[2013-01-16 18:31:56] googleguy@php.net
*Correction to my last comment
"This is not a bug, because the condition of the loop is NOT dependent upon
curl_multi_select."
------------------------------------------------------------------------
[2013-01-16 18:31:05] googleguy@php.net
This is not a bug, because the condition of the loop is dependent upon
curl_multi_select. If the curl_multi_select returns -1 the code within the loop
body is simply not executed. This still does not create an infinite loop under
normal conditions because eventually if all of the curl handles timeout they are
freed from the select resource handle.
------------------------------------------------------------------------
[2013-01-16 15:05:07] googleguy@php.net
Related To: Bug #63936
------------------------------------------------------------------------
[2013-01-03 15:09:09] dean at ovts dot com dot au
Whoops... I meant to change all the $curlMH variables to $mh to match the previous code snippet, but
I only did the first one. So '$curlMH' in the above code should actually be
'$mh'. Sorry about that!
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=63842
--
Edit this bug report at https://bugs.php.net/bug.php?id=63842&edit=1