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

index 365b6c8e5ff82d5a024e37ac523d9171bc0edd72..b913a42fdd97c071580c37bd4c705288ed3e5d23 100644 (file)
@@ -333,8 +333,15 @@ static size_t php_stdiop_read(php_stream *stream, char *buf, size_t count TSRMLS
                        return 0;
                }
                ret = read(data->fd, buf, count);
-               
-               stream->eof = (ret == 0 || (ret == (size_t)-1 && errno != EWOULDBLOCK));
+
+               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 && errno != EINTR));
                                
        } else {
 #if HAVE_FLUSHIO