Skip to content

Commit

Permalink
Merge pull request #7 from ElvenSpellmaker/fix/scheduler-valid-bug
Browse files Browse the repository at this point in the history
Fixes #6.
  • Loading branch information
ElvenSpellmaker committed May 22, 2015
2 parents 038dd91 + ac11dde commit 099e287
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/PipeSys/Scheduler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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 );
Expand Down

0 comments on commit 099e287

Please sign in to comment.