Skip to content

Commit 099e287

Browse files
Merge pull request #7 from ElvenSpellmaker/fix/scheduler-valid-bug
Fixes #6.
2 parents 038dd91 + ac11dde commit 099e287

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/PipeSys/Scheduler.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public function run()
100100
continue;
101101

102102
// If the pipe is dead then invalidate the command...
103-
if( ! $this->handleGenResponse( $genResponse, $key ) )
103+
if( ! $this->handleGenResponse( $genResponse, $key, $invalidCommands ) )
104104
$invalidCommands[$key] = true;
105105
}
106106

@@ -129,7 +129,7 @@ protected function prepareCommands()
129129

130130
// Run the generators once and handle the responses.
131131
$genResponse = $this->commandGenerators[$key]->current();
132-
$this->handleGenResponse($genResponse, $key);
132+
$this->handleGenResponse( $genResponse, $key, $invalidCommands );
133133

134134
if( ! $this->commandGenerators[$key]->valid() )
135135
$invalidCommands[$key] = true;
@@ -201,8 +201,10 @@ protected function runGen($key, $readLine)
201201
*
202202
* @param string|ReadIntent $genResponse
203203
* @param integer $key
204+
* @param array $invalidCommands
204205
*/
205-
protected function handleGenResponse($genResponse, $key)
206+
protected function handleGenResponse($genResponse, $key,
207+
array $invalidCommands)
206208
{
207209
if( $genResponse instanceof ReadIntent )
208210
$this->readIntents[$key] = true;
@@ -215,8 +217,8 @@ protected function handleGenResponse($genResponse, $key)
215217
else
216218
{
217219
// If we are trying to write to a dead pipe return false...
218-
if( isset( $this->commandGenerators[$key + 1] )
219-
&& ! $this->commandGenerators[$key + 1]->valid() )
220+
if( isset( $invalidCommands[$key + 1] )
221+
&& $invalidCommands[$key + 1] )
220222
return false;
221223

222224
$this->buffers[$key]->write( $genResponse );

0 commit comments

Comments
 (0)