Bug #77030 [Opn->Asn]: curl_multi_select() return value is inconsistent
Edit report at https://bugs.php.net/bug.php?id=77030&edit=1
ID: 77030
Updated by: nikic@php.net
Reported by: php-bugs at xpaw dot me
Summary: curl_multi_select() return value is inconsistent
-Status: Open
+Status: Assigned
Type: Bug
Package: cURL related
Operating System: All of them
PHP Version: 7.2.11
-Assigned To:
+Assigned To: pierrick
Block user comment: N
Private report: N
New Comment:
Assigning to pierrick who landed the fix for bug #76480. We may have to revert this on the stable
branches due to the BC break, if it can't be fixed in some other way.
Previous Comments:
------------------------------------------------------------------------
[2018-10-18 09:02:11] php-bugs at xpaw dot me
Description:
------------
Looking at the source code of how curl_multi_select() is implemented, there's various different
ways of which values it can return.
And these includes:
- Number of descriptors from curl_multi_wait or curl_multi_fdset depending on the version
- curl version before 7.48 can set numfds to -1 in curl_multi_wait
- native call to select() can return -1 (without any curl error being set, so this return value
highly depends on OS it seems)
Basically, many different little differences like that can produce wildly different results, and
it's very hard to write a consistent library that uses multi curl.
Here's my library that implements multi curl: https://github.com/xPaw/Crimp.php
And after PHP 7.2.11 released, which uses curl_multi_wait, it looks like the current fix would be:
```
if( $Running ) {
$Descriptors = curl_multi_select( $Master, 0.1 );
if( $Descriptors === -1 && curl_multi_errno( $Master ) !== CURLM_OK ) {
throw new \RuntimeException( 'curl_multi_select failed. error: ' . curl_multi_errno(
$Master ) );
}
// count number of repeated zero numfds
if( $Descriptors === 0 ) {
if( ++$Repeats > 1 ) {
usleep( 100 );
}
} else {
$Repeats = 0;
}
}
```
Note that I added a curl_multi_errno check if curl_multi_select returns -1.
I'm not entirely sure what's the elegant way of fixing this would be, but this is clearly
a problem that keeps on reoccurring, for example in bug #74334
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=77030&edit=1
Thread (4 messages)