]> granicus.if.org Git - php/commitdiff
Fix sticky EOF problem
authorSascha Schumann <sas@php.net>
Thu, 30 Jan 2003 21:06:34 +0000 (21:06 +0000)
committerSascha Schumann <sas@php.net>
Thu, 30 Jan 2003 21:06:34 +0000 (21:06 +0000)
Sometimes streams signal a temporary EOF, because all current data
has been consumed. But that does not preclude the possibility that
more data will become available later.

Thus we must not treat eof in the read path as final.

Now, "tail -f" like scripts work again.

main/streams.c

index 4792fc3fb0d835e1bf2a7f4c1b9e9d8e63004077..a1fa323df4f547f957288ac103984dcdb89d3bca 100755 (executable)
@@ -521,8 +521,7 @@ static void php_stream_fill_read_buffer(php_stream *stream, size_t size TSRMLS_D
        if (stream->writepos - stream->readpos < (off_t)size) {
                size_t justread = 0;
        
-               if (stream->eof)
-                       return;
+               /* ignore eof here; the underlying state might have changed */
                
                /* no; so lets fetch more data */
                
@@ -581,7 +580,8 @@ PHPAPI size_t _php_stream_read(php_stream *stream, char *buf, size_t size TSRMLS
                        didread += toread;
                }
 
-               if (size == 0 || stream->eof) {
+               /* ignore eof here; the underlying state might have changed */
+               if (size == 0) {
                        break;
                }