Browse Source

Improve EOF detection. Fixes #19970.

experimental/threaded
Wez Furlong 24 years ago
parent
commit
e0c0264935
  1. 2
      main/network.c
  2. 5
      main/streams.c

2
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;
}
}

5
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

Loading…
Cancel
Save