Skip to content

Commit

Permalink
Merge pull request #56 from CharlotteDunoisLabs/patch-child-fd
Browse files Browse the repository at this point in the history
Use native PHP indexing for child process file descriptors
  • Loading branch information
clue committed Jan 17, 2019
2 parents 72ae332 + 508ec77 commit 9637fed
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/ChildProcess/Adapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,17 +202,18 @@ public function mkdir($path, $mode = self::CREATION_MODE)
*/
public function open($path, $flags, $mode = self::CREATION_MODE)
{
$id = null;
return \WyriHaximus\React\ChildProcess\Messenger\Factory::parentFromClass(self::CHILD_CLASS_NAME, $this->loop)->then(function (Messenger $messenger) use (&$id, $path, $flags, $mode) {
$id = count($this->fileDescriptors);
$this->fileDescriptors[$id] = $messenger;
return \WyriHaximus\React\ChildProcess\Messenger\Factory::parentFromClass(self::CHILD_CLASS_NAME, $this->loop)->then(function (Messenger $messenger) use ($path, $flags, $mode) {
$this->fileDescriptors[] = $messenger;
\end($this->fileDescriptors);
$id = \key($this->fileDescriptors);

return $this->fileDescriptors[$id]->rpc(Factory::rpc('open', [
'path' => $path,
'flags' => $flags,
'mode' => $mode,
]));
})->then(function () use (&$id) {
return $id;
]))->then(function () use ($id) {
return $id;
});
});
}

Expand Down

0 comments on commit 9637fed

Please sign in to comment.