]> granicus.if.org Git - php/commitdiff
- Merge from PHP_5_3:
authorJani Taskinen <jani@php.net>
Sat, 25 Jul 2009 13:09:03 +0000 (13:09 +0000)
committerJani Taskinen <jani@php.net>
Sat, 25 Jul 2009 13:09:03 +0000 (13:09 +0000)
r280810 | kalle: Fixed compiler warnings
r276286 | iliaa: Fixed bug #47477 (php_curl_stream_read() unnecessarily sleeps 15 secs under heavy load)

ext/curl/streams.c

index 22ea72b0f3091f8849fb90e7a697bcc1ea854277..0e1a55a7ea0c4c5ace7825f454f7d7516a6846bd 100644 (file)
@@ -129,7 +129,7 @@ static int on_progress_avail(php_stream *stream, double dltotal, double dlnow, d
 
        /* our notification system only works in a single direction; we should detect which
         * direction is important and use the correct values in this call */
-       php_stream_notify_progress(stream->context, dlnow, dltotal);
+       php_stream_notify_progress(stream->context, (size_t) dlnow, (size_t) dltotal);
        return 0;
 }
 
@@ -167,7 +167,8 @@ static size_t php_curl_stream_read(php_stream *stream, char *buf, size_t count T
                        tv.tv_sec = 15; /* TODO: allow this to be configured from the script */
 
                        /* wait for data */
-                       switch (select(curlstream->maxfd + 1, &curlstream->readfds, &curlstream->writefds, &curlstream->excfds, &tv)) {
+                       switch ((curlstream->maxfd < 0) ? 1 : 
+                                       select(curlstream->maxfd + 1, &curlstream->readfds, &curlstream->writefds, &curlstream->excfds, &tv)) {
                                case -1:
                                        /* error */
                                        return 0;
@@ -180,7 +181,8 @@ static size_t php_curl_stream_read(php_stream *stream, char *buf, size_t count T
                                                curlstream->mcode = curl_multi_perform(curlstream->multi, &curlstream->pending);
                                        } while (curlstream->mcode == CURLM_CALL_MULTI_PERFORM);
                        }
-               } while (curlstream->readbuffer.readpos >= curlstream->readbuffer.writepos && curlstream->pending > 0);
+               } while (curlstream->maxfd >= 0 &&
+                               curlstream->readbuffer.readpos >= curlstream->readbuffer.writepos && curlstream->pending > 0);
 
        }