]> granicus.if.org Git - php/commitdiff
Add retry for interrupted reads and graceful handling for failed retries
authorSara Golemon <pollita@php.net>
Fri, 23 Feb 2007 23:08:40 +0000 (23:08 +0000)
committerSara Golemon <pollita@php.net>
Fri, 23 Feb 2007 23:08:40 +0000 (23:08 +0000)
main/streams/plain_wrapper.c

index 83bf4c4daba1f1b702b355c1015372bc429fda19..268883848185b3ffda2c00f029b4bf503b6dec1f 100644 (file)
@@ -337,8 +337,15 @@ static size_t php_stdiop_read(php_stream *stream, char *buf, size_t count TSRMLS
                        return 0;
                }
                ret = read(data->fd, buf, count);
+
+               if (ret == (size_t)-1 && errno == EINTR) {
+                       /* Read was interrupted, retry once,
+                          If read still fails, giveup with feof==0
+                          so script can retry if desired */
+                       ret = read(data->fd, buf, count);
+               }
                
-               stream->eof = (ret == 0 || (ret == (size_t)-1 && errno != EWOULDBLOCK));
+               stream->eof = (ret == 0 || (ret == (size_t)-1 && errno != EWOULDBLOCK && errno != EINTR));
                                
        } else {
 #if HAVE_FLUSHIO