From: Sara Golemon Date: Fri, 23 Feb 2007 23:08:40 +0000 (+0000) Subject: Add retry for interrupted reads and graceful handling for failed retries X-Git-Tag: RELEASE_1_0_1~175 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3b00d29d5a791844eee851d63ceb5e1d10965d76;p=php Add retry for interrupted reads and graceful handling for failed retries --- diff --git a/main/streams/plain_wrapper.c b/main/streams/plain_wrapper.c index 83bf4c4dab..2688838481 100644 --- a/main/streams/plain_wrapper.c +++ b/main/streams/plain_wrapper.c @@ -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