diff options
author | Sara Golemon <pollita@php.net> | 2007-02-23 23:09:14 +0000 |
---|---|---|
committer | Sara Golemon <pollita@php.net> | 2007-02-23 23:09:14 +0000 |
commit | c3935671cd12182a39c15b973c99b6b89b94920a (patch) | |
tree | 91e7e71749e9364ac96c97bc3b81988a098dbc00 /main/streams/plain_wrapper.c | |
parent | 59bcd2372d08e1c0da7c1f6d430ebf4b19858c7c (diff) | |
download | php-git-c3935671cd12182a39c15b973c99b6b89b94920a.tar.gz |
MFH (r-1.82): Add retry for interrupted reads and graceful handling for failed retries
Diffstat (limited to 'main/streams/plain_wrapper.c')
-rw-r--r-- | main/streams/plain_wrapper.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/main/streams/plain_wrapper.c b/main/streams/plain_wrapper.c index 365b6c8e5f..b913a42fdd 100644 --- a/main/streams/plain_wrapper.c +++ b/main/streams/plain_wrapper.c @@ -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 |