|  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
 [2015-07-13 07:57 UTC] xiaoyjy at mail dot com
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.

        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) {

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

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


Add a Patch

Pull Requests

Add a Pull Request


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]
I don't think this is a bug, as described here:

"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

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

PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Fri Mar 05 16:01:24 2021 UTC