Bug #77030 [Asn]: curl_multi_select() return value is inconsistent

From: Date: Wed, 22 May 2019 03:23:01 +0000
Subject: Bug #77030 [Asn]: curl_multi_select() return value is inconsistent
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-220931@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=77030&edit=1 ID: 77030 Updated by: bishop@php.net Reported by: php-bugs at xpaw dot me Summary: curl_multi_select() return value is inconsistent Status: Assigned Type: Bug Package: cURL related Operating System: All of them PHP Version: 7.2.11 Assigned To: pierrick Block user comment: N Private report: N New Comment: How should we proceed, at this point? The documentation reflects the new return values, and those return values are pretty-well established in released versions (having been out for more than 6 months now). "Wont Fix" seems appropriate... I did add a note to the documentation[1] [1]: https://www.php.net/manual/en/function.curl-multi-select.php#123869 Previous Comments: ------------------------------------------------------------------------ [2018-10-18 10:37:50] php-bugs at xpaw dot me Please note that this issue aims to create a discussion on the overall design of how curl_multi_select function is implemented, as before using curl_multi_wait internally, there were already cases of inconsistent return values. ------------------------------------------------------------------------ [2018-10-18 10:32:58] nikic@php.net 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. ------------------------------------------------------------------------ [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

« previous php.bugs (#220931) next »