]> granicus.if.org Git - php/commitdiff
MFB: Fix for bug #22199
authorWez Furlong <wez@php.net>
Thu, 13 Feb 2003 21:08:04 +0000 (21:08 +0000)
committerWez Furlong <wez@php.net>
Thu, 13 Feb 2003 21:08:04 +0000 (21:08 +0000)
main/streams.c

index 097b8155648bc50df57197c8ba1a7925d69f2c9e..2a97033e4a7f8c8abbe455de2f7ab46b293fcd6d 100755 (executable)
@@ -869,14 +869,17 @@ PHPAPI size_t _php_stream_write(php_stream *stream, const char *buf, size_t coun
                        justwrote = stream->ops->write(stream, buf, towrite TSRMLS_CC);
                }
                if (justwrote > 0) {
-                       stream->position += justwrote;
                        buf += justwrote;
                        count -= justwrote;
                        didwrite += justwrote;
                        
-                       /* FIXME: invalidate the whole readbuffer */
-                       stream->writepos = 0;
-                       stream->readpos = 0;
+                       /* Only screw with the buffer if we can seek, otherwise we lose data
+                        * buffered from fifos and sockets */
+                       if (stream->ops->seek && (stream->flags & PHP_STREAM_FLAG_NO_SEEK) == 0) {
+                               stream->position += justwrote;
+                               stream->writepos = 0;
+                               stream->readpos = 0;
+                       }
                } else {
                        break;
                }