Exit process if input or output stream is broken
parent
a19d225a7a
commit
2c1d65db68
|
@ -29,6 +29,10 @@ class ProtocolStreamReader implements ProtocolReader
|
|||
{
|
||||
$this->input = $input;
|
||||
Loop\addReadStream($this->input, function() {
|
||||
if (feof($this->input)) {
|
||||
die;
|
||||
}
|
||||
|
||||
while (($c = fgetc($this->input)) !== false && $c !== '') {
|
||||
$this->buffer .= $c;
|
||||
switch ($this->parsingMode) {
|
||||
|
|
|
@ -31,16 +31,7 @@ class ProtocolStreamWriter implements ProtocolWriter
|
|||
$totalBytesWritten = 0;
|
||||
|
||||
while ($totalBytesWritten < $msgSize) {
|
||||
error_clear_last();
|
||||
$bytesWritten = @fwrite($this->output, substr($data, $totalBytesWritten));
|
||||
if ($bytesWritten === false) {
|
||||
$error = error_get_last();
|
||||
if ($error !== null) {
|
||||
throw new RuntimeException('Could not write message: ' . error_get_last()['message']);
|
||||
} else {
|
||||
throw new RuntimeException('Could not write message');
|
||||
}
|
||||
}
|
||||
$bytesWritten = fwrite($this->output, substr($data, $totalBytesWritten));
|
||||
$totalBytesWritten += $bytesWritten;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue