Skip to content

Commit

Permalink
Fix resource input streams
Browse files Browse the repository at this point in the history
The read watcher needs to be disabled now, because immediate reads will process the next immediate read now in the next tick.

Fixes #38.
  • Loading branch information
kelunik committed Mar 11, 2018
1 parent ca9128a commit 9f60974
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions lib/ResourceInputStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,11 @@ public function __construct($stream, int $chunkSize = self::DEFAULT_CHUNK_SIZE)
$data = null; // Stream closed, resolve read with null.
}

Loop::disable($watcher);

$temp = $deferred;
$deferred = null;
$temp->resolve($data);

if ($deferred === null) { // Only disable watcher if no further read was requested.
Loop::disable($watcher);
}
});

$this->immediateCallable = static function ($watcherId, $data) use (&$deferred) {
Expand Down

0 comments on commit 9f60974

Please sign in to comment.