php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70060 write events should be disabled in curl_multi_select
Submitted: 2015-07-13 07:57 UTC Modified: 2015-07-15 02:49 UTC
From: xiaoyjy at mail dot com Assigned:
Status: Not a bug Package: cURL related
PHP Version: 5.6.11 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: xiaoyjy at mail dot com
New email:
PHP Version: OS:

 

 [2015-07-13 07:57 UTC] xiaoyjy at mail dot com
Description:
------------
As a clent fd, writefds are always available, the select function will always return immediately if the writefds is enabled. but we only care about read events in this case.

PHP_FUNCTION(curl_multi_select)
{
        zval           *z_mh;
        php_curlm      *mh;
        fd_set          readfds;
        fd_set          writefds;
        fd_set          exceptfds;
        int             maxfd;
        double          timeout = 1.0;
        struct timeval  to;

        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|d", &z_mh, &timeout) == FAILURE) {
                return;
        }

        ZEND_FETCH_RESOURCE(mh, php_curlm *, &z_mh, -1, le_curl_multi_handle_name, le_curl_multi_handle);

        _make_timeval_struct(&to, timeout);                                                                                
                                                                                                                           
        FD_ZERO(&readfds);                                                                                                 
        FD_ZERO(&writefds);                                                                                                
        FD_ZERO(&exceptfds);                                                                                               
                                                                                                                           
        curl_multi_fdset(mh->multi, &readfds, &writefds, &exceptfds, &maxfd);                                              
        if (maxfd == -1) {                                                                                                 
                RETURN_LONG(-1);                                                                                           
        }                                                                                                                  
                                                                                                                           
        RETURN_LONG(select(maxfd + 1, &readfds, &writefds, &exceptfds, &to));                                              
}   




Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-07-13 08:06 UTC] xiaoyjy at mail dot com
-Package: HTTP related +Package: cURL related
 [2015-07-13 08:06 UTC] xiaoyjy at mail dot com
change Package to cURL ralated
 [2015-07-13 09:07 UTC] laruence@php.net
I don't think this is a bug, as described here: http://curl.haxx.se/libcurl/c/curl_multi_fdset.html

"This function extracts file descriptor information from a given multi_handle. libcurl returns its fd_set sets. The application can use these to select() on, but be sure to FD_ZERO them before calling this function as curl_multi_fdset only adds its own descriptors, it doesn't zero or otherwise remove any others. The curl_multi_perform function should be called as soon as one of them is ready to be read from or written to."

that means, the write event is interested by libcurl, the requests are not sent completely yet.

so, you should use a while loop, if the state changed, you should call curl_multi_exec immedidately and always checking running request in the mean time to achieve your goals

thanks
 [2015-07-15 02:49 UTC] laruence@php.net
-Status: Open +Status: Not a bug
 [2015-07-15 02:49 UTC] laruence@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php


 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sat Sep 21 13:01:27 2019 UTC