]> granicus.if.org Git - php/commitdiff
Avoid calling select if maxfd returned by curl_multi_fdset is -1
authorPierrick Charron <pierrick@php.net>
Sat, 22 Sep 2012 14:15:40 +0000 (10:15 -0400)
committerPierrick Charron <pierrick@php.net>
Sat, 22 Sep 2012 14:15:40 +0000 (10:15 -0400)
As per libcurl documentation :

When libcurl returns -1 in max_fd, it is because libcurl currently
does something that isn't possible for your application to monitor
with a socket and unfortunately you can then not know exactly when
the current action is completed using select().

ext/curl/multi.c

index 034aa65c28f0e7cd5329f9edf4c96d4c5668ebf2..53e97b80f81f80b0b397540ff068617d01964034 100644 (file)
@@ -191,6 +191,9 @@ PHP_FUNCTION(curl_multi_select)
        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));
 }
 /* }}} */