From ac11dde5fae39ff16166ee5053d9202dc505c3d8 Mon Sep 17 00:00:00 2001 From: ElvenSpellmaker Date: Fri, 22 May 2015 15:57:04 +0100 Subject: [PATCH] Fixes #6. --- src/PipeSys/Scheduler.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/PipeSys/Scheduler.php b/src/PipeSys/Scheduler.php index d88b50e..fe3473c 100644 --- a/src/PipeSys/Scheduler.php +++ b/src/PipeSys/Scheduler.php @@ -100,7 +100,7 @@ public function run() continue; // If the pipe is dead then invalidate the command... - if( ! $this->handleGenResponse( $genResponse, $key ) ) + if( ! $this->handleGenResponse( $genResponse, $key, $invalidCommands ) ) $invalidCommands[$key] = true; } @@ -129,7 +129,7 @@ protected function prepareCommands() // Run the generators once and handle the responses. $genResponse = $this->commandGenerators[$key]->current(); - $this->handleGenResponse($genResponse, $key); + $this->handleGenResponse( $genResponse, $key, $invalidCommands ); if( ! $this->commandGenerators[$key]->valid() ) $invalidCommands[$key] = true; @@ -201,8 +201,10 @@ protected function runGen($key, $readLine) * * @param string|ReadIntent $genResponse * @param integer $key + * @param array $invalidCommands */ - protected function handleGenResponse($genResponse, $key) + protected function handleGenResponse($genResponse, $key, + array $invalidCommands) { if( $genResponse instanceof ReadIntent ) $this->readIntents[$key] = true; @@ -215,8 +217,8 @@ protected function handleGenResponse($genResponse, $key) else { // If we are trying to write to a dead pipe return false... - if( isset( $this->commandGenerators[$key + 1] ) - && ! $this->commandGenerators[$key + 1]->valid() ) + if( isset( $invalidCommands[$key + 1] ) + && $invalidCommands[$key + 1] ) return false; $this->buffers[$key]->write( $genResponse );