Skip to content

Commit 77276eb

Browse files
committed
HHVM does not support, nor require, stream_set_read_buffer()
1 parent 6d665ce commit 77276eb

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/Stream.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,16 @@ public function __construct($stream, LoopInterface $loop)
2424
}
2525

2626
stream_set_blocking($this->stream, 0);
27-
stream_set_read_buffer($this->stream, 0);
27+
28+
// Use unbuffered read operations on the underlying stream resource.
29+
// Reading chunks from the stream may otherwise leave unread bytes in
30+
// PHP's stream buffers which some event loop implementations do not
31+
// trigger events on (edge triggered).
32+
// This does not affect the default event loop implementation (level
33+
// triggered), so we can ignore platforms not supporting this (HHVM).
34+
if (function_exists('stream_set_read_buffer')) {
35+
stream_set_read_buffer($this->stream, 0);
36+
}
2837

2938
$this->loop = $loop;
3039
$this->buffer = new Buffer($this->stream, $this->loop);

0 commit comments

Comments
 (0)