Bug #77030 [NEW]: curl_multi_select() return value is inconsistent
From: php-bugs at xpaw dot me
Operating system: All of them
PHP version: 7.2.11
Package: cURL related
Bug Type: Bug
Bug description:curl_multi_select() return value is inconsistent
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 bug report at https://bugs.php.net/bug.php?id=77030&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=77030&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=77030&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=77030&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=77030&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=77030&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=77030&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=77030&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=77030&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=77030&r=support
Expected behavior: https://bugs.php.net/fix.php?id=77030&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=77030&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=77030&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=77030&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=77030&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=77030&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=77030&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=77030&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=77030&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=77030&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=77030&r=mysqlcfg
Thread (4 messages)
- php-bugs at xpaw dot me