summaryrefslogtreecommitdiff
path: root/main/streams.c
diff options
context:
space:
mode:
Diffstat (limited to 'main/streams.c')
-rwxr-xr-xmain/streams.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/main/streams.c b/main/streams.c
index 097b815564..2a97033e4a 100755
--- a/main/streams.c
+++ b/main/streams.c
@@ -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;
}