]> granicus.if.org Git - php/commitdiff
Set the EOF indicator after each read attempt.
authorWez Furlong <wez@php.net>
Wed, 8 Oct 2003 10:55:51 +0000 (10:55 +0000)
committerWez Furlong <wez@php.net>
Wed, 8 Oct 2003 10:55:51 +0000 (10:55 +0000)
This prevents it getting stuck in the on position.

main/streams/plain_wrapper.c
main/streams/xp_socket.c

index a7ac4fa5e78cf81883559d612a878093577c6d7d..1f060ec6663302df65c96760ab7024c486d7e580 100644 (file)
@@ -370,8 +370,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 == -1 && errno != EWOULDBLOCK))
-                       stream->eof = 1;
+               stream->eof = (ret == 0 || (ret == -1 && errno != EWOULDBLOCK));
                                
        } else {
 #if HAVE_FLUSHIO
@@ -382,8 +381,7 @@ static size_t php_stdiop_read(php_stream *stream, char *buf, size_t count TSRMLS
 
                ret = fread(buf, 1, count, data->file);
 
-               if (feof(data->file))
-                       stream->eof = 1;
+               stream->eof = feof(data->file);
        }
        return ret;
 }
index 1663a85ffa6debd581299df6e7b14cd5d1771be6..193958fa6e18172d24b47db0b2bef63751d38620 100644 (file)
@@ -124,9 +124,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 == -1 && php_socket_errno() != EWOULDBLOCK)) {
-               stream->eof = 1;
-       }
+       stream->eof = (nr_bytes == 0 || (nr_bytes == -1 && php_socket_errno() != EWOULDBLOCK));
 
        if (nr_bytes > 0) {
                php_stream_notify_progress_increment(stream->context, nr_bytes, 0);