From e0c02649355a0b4233b32fcf4d5552e287292273 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Fri, 18 Oct 2002 12:15:04 +0000 Subject: [PATCH] Improve EOF detection. Fixes #19970. --- main/network.c | 2 +- main/streams.c | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/main/network.c b/main/network.c index fb8e753fe9..d9c4c5d33c 100644 --- a/main/network.c +++ b/main/network.c @@ -940,7 +940,7 @@ static size_t php_sockop_read(php_stream *stream, char *buf, size_t count TSRMLS nr_bytes = recv(sock->socket, buf, count, 0); - if (nr_bytes == 0 || (nr_bytes < 0 && php_socket_errno() != EWOULDBLOCK)) { + if (nr_bytes == 0 || (nr_bytes < count && php_socket_errno() != EWOULDBLOCK)) { stream->eof = 1; } } diff --git a/main/streams.c b/main/streams.c index 8597d6bf33..8b6a40c1e1 100755 --- a/main/streams.c +++ b/main/streams.c @@ -1280,7 +1280,7 @@ static size_t php_stdiop_read(php_stream *stream, char *buf, size_t count TSRMLS if (data->fd >= 0) { ret = read(data->fd, buf, count); - if (ret == 0 || (ret < 0 && errno != EWOULDBLOCK)) + if (ret == 0 || (ret < count && errno != EWOULDBLOCK)) stream->eof = 1; } else { @@ -1673,7 +1673,7 @@ static ssize_t stream_cookie_writer(void *cookie, const char *buffer, size_t siz static int stream_cookie_seeker(void *cookie, fpos_t *position, int whence) { TSRMLS_FETCH(); - + *position = php_stream_seek((php_stream *)cookie, *position, whence); if (*position == -1) @@ -1684,7 +1684,6 @@ static int stream_cookie_seeker(void *cookie, fpos_t *position, int whence) static int stream_cookie_seeker(void *cookie, off_t position, int whence) { TSRMLS_FETCH(); - return php_stream_seek((php_stream *)cookie, position, whence); } #endif -- 2.40.0