Doc #61141 [Com]: curl_multi_select returns -1
| From: | amoo_miki at yahoo dot com | Date: | Sat, 22 Sep 2012 14:16:33 +0000 |
| Subject: | Doc #61141 [Com]: curl_multi_select returns -1 | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-8891@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=61141&edit=1
ID: 61141
Comment by: amoo_miki at yahoo dot com
Reported by: amoo_miki at yahoo dot com
Summary: curl_multi_select returns -1
Status: Not a bug
Type: Documentation Problem
Package: cURL related
Operating System: Windows 7 x64
PHP Version: 5.3.10
Assigned To: pierrick
Block user comment: N
Private report: N
New Comment:
Got it. Thanks for explaining it.
Can't say i am happy with what libcurl would say :)
Also, i believe this would call for a change in "Example 1" on http://php.net/manual/en/function.curl-multi-init.php
Thanks again.
Previous Comments:
------------------------------------------------------------------------
[2012-09-22 14:13:38] pierrick@php.net
The change that introduced your problem is somewhere in libcurl. You could submit
a bug to libcurl, but I'm pretty sure they will come with the same answer as I
did since it's documented.
I know that the code will work even if you never call curl_multi_select but I
would recommend you to use it anyway to make sure you'll not consume all your cpu
resources and I would follow the libcurl recommandation to sleep some time before
executing the curl_multi_exec
------------------------------------------------------------------------
[2012-09-22 14:03:06] amoo_miki at yahoo dot com
i reread your comment about
The libcurl documentations says "When max_fd returns
with -1, you need to wait a while and then proceed and call curl_multi_perform
anyway"...
... the keyword being "anyway".
------------------------------------------------------------------------
[2012-09-22 13:56:43] amoo_miki at yahoo dot com
Gotcha. The code change you propose works, but not sure why it doesn't make sense to me.
while ($active && $mrc == CURLM_OK) {
do { $mrc = curl_multi_exec($mh, $active); }
while ($mrc == CURLM_CALL_MULTI_PERFORM);
}
The above piece works too, without needing the timeout, but that mean skipping the curl_multi_select
altogether, practically what you found is that we can do without checking curl_multi_select which
doesn't solve the problem with curl_multi_select.
See where i am going?
Also, thanks for looking into this. curl_multi_select is a very useful function and it would be
crazy not to use it.
------------------------------------------------------------------------
[2012-09-22 13:49:52] amoo_miki at yahoo dot com
I should also add that, the sample code, without the sleep works perfectly fine on non-windows
setups. I verified it using 5.3.13 which uses cURL 7.24.0 on OSX.
------------------------------------------------------------------------
[2012-09-22 13:44:50] pierrick@php.net
No, sorry if I was unclear. The libcurl documentations says "When max_fd returns
with -1, you need to wait a while and then proceed and call curl_multi_perform
anyway".
If you translate this in PHP (That was where I was unclear) : "When
curl_multi_select returns with -1, you need to wait a while and then proceed and
call curl_multi_exec anyway"
Then, you should have something like this :
while ($active && $mrc == CURLM_OK) {
if (curl_multi_select($mh) == -1) usleep(100);
do { $mrc = curl_multi_exec($mh, $active); }
while ($mrc == CURLM_CALL_MULTI_PERFORM);
}
------------------------------------------------------------------------
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=61141
--
Edit this bug report at https://bugs.php.net/bug.php?id=61141&edit=1