]> granicus.if.org Git - php/commitdiff
Improve EOF detection. Fixes #19970.
authorWez Furlong <wez@php.net>
Fri, 18 Oct 2002 12:15:04 +0000 (12:15 +0000)
committerWez Furlong <wez@php.net>
Fri, 18 Oct 2002 12:15:04 +0000 (12:15 +0000)
main/network.c
main/streams.c

index fb8e753fe97d0f91c4974bb038685fab588eb676..d9c4c5d33c2923aa251732c9f7f15ad56c9538f3 100644 (file)
@@ -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;
                }
        }
index 8597d6bf33ff2986bd8f5b794ecd881d5e7553bd..8b6a40c1e1c0764d229ecc5431b75370e45ec403 100755 (executable)
@@ -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