1
0
Fork 0

make input stream non-blocking

pull/31/head
Stephan Unverwerth 2016-09-29 00:08:07 +02:00
parent 9036ae84fd
commit 5f8e37be9e
2 changed files with 3 additions and 4 deletions

View File

@ -27,6 +27,8 @@ else {
$outputStream = STDOUT; $outputStream = STDOUT;
} }
stream_set_blocking($inputStream, false);
$server = new LanguageServer(new ProtocolStreamReader($inputStream), new ProtocolStreamWriter($outputStream)); $server = new LanguageServer(new ProtocolStreamReader($inputStream), new ProtocolStreamWriter($outputStream));
Loop\run(); Loop\run();

View File

@ -30,7 +30,7 @@ class ProtocolStreamReader implements ProtocolReader
{ {
$this->input = $input; $this->input = $input;
Loop\addReadStream($this->input, function() { Loop\addReadStream($this->input, function() {
while(($c = fgetc($this->input)) !== false) { while(($c = fgetc($this->input)) !== false && $c !== '') {
$this->buffer .= $c; $this->buffer .= $c;
switch ($this->parsingMode) { switch ($this->parsingMode) {
case ParsingMode::HEADERS: case ParsingMode::HEADERS:
@ -54,9 +54,6 @@ class ProtocolStreamReader implements ProtocolReader
$this->parsingMode = ParsingMode::HEADERS; $this->parsingMode = ParsingMode::HEADERS;
$this->headers = []; $this->headers = [];
$this->buffer = ''; $this->buffer = '';
// after reading a full message, leave to allow different tasks to run
return;
} }
break; break;
} }