| @@ -59,6 +59,10 @@ | ||
| 59 | 59 | }); | 
| 60 | 60 | } | 
| 61 | 61 | |
| 62 | + /** | |
| 63 | + * @param string $host | |
| 64 | + * @param integer $retry | |
| 65 | + */ | |
| 62 | 66 | protected function createInternalWithRetryAsync($host, $docroot, $router, $retry) | 
| 63 | 67 |      { | 
| 64 | 68 | return $this | 
| @@ -28,20 +28,20 @@ discard block | ||
| 28 | 28 | $process = new BuiltinServer($host, $docroot, $router, $this->php); | 
| 29 | 29 | |
| 30 | 30 | $process->start($this->loop); | 
| 31 | -        $process->on('exit', function ($code) use ($deferred) { | |
| 31 | +        $process->on('exit', function($code) use ($deferred) { | |
| 32 | 32 |              $this->stderr->write("Process exit with code $code\n"); | 
| 33 | 33 | $deferred->reject(); | 
| 34 | 34 | }); | 
| 35 | 35 | |
| 36 | 36 | $process->stdin->close(); | 
| 37 | 37 | $process->stdout->close(); | 
| 38 | -        $process->stderr->on('data', function ($output) use ($deferred) { | |
| 38 | +        $process->stderr->on('data', function($output) use ($deferred) { | |
| 39 | 39 | $this->stderr->write($output); | 
| 40 | 40 | $deferred->reject(); | 
| 41 | 41 | }); | 
| 42 | 42 | |
| 43 | 43 | $timer = new Deferred; | 
| 44 | -        $this->loop->addTimer(0.05, function () use ($timer, $process) { | |
| 44 | +        $this->loop->addTimer(0.05, function() use ($timer, $process) { | |
| 45 | 45 |              if (DIRECTORY_SEPARATOR === '\\') { | 
| 46 | 46 | // Pipes opened by proc_open() can break stream_select() loop in Windows. | 
| 47 | 47 | // This fix might do the trick... | 
| @@ -53,7 +53,7 @@ discard block | ||
| 53 | 53 | return \React\Promise\race([ | 
| 54 | 54 | $deferred->promise(), | 
| 55 | 55 | $timer->promise(), | 
| 56 | -        ])->then(null, function () use ($process) { | |
| 56 | +        ])->then(null, function() use ($process) { | |
| 57 | 57 | $process->terminate(); | 
| 58 | 58 | return new RejectedPromise; | 
| 59 | 59 | }); | 
| @@ -63,7 +63,7 @@ discard block | ||
| 63 | 63 |      { | 
| 64 | 64 | return $this | 
| 65 | 65 | ->createInternalAsync($host, $docroot, $router) | 
| 66 | -        ->then(null, function () use ($host, $docroot, $router, $retry) { | |
| 66 | +        ->then(null, function() use ($host, $docroot, $router, $retry) { | |
| 67 | 67 |              if ($retry < 1) { | 
| 68 | 68 |                  throw new \RuntimeException('Failed to launch server.'); | 
| 69 | 69 | } | 
| @@ -18,13 +18,13 @@ | ||
| 18 | 18 | public function __invoke(ConnectionInterface $conn) | 
| 19 | 19 |      { | 
| 20 | 20 | $sink = new Sink($conn); | 
| 21 | -        $this->master->queue->executeAsync(function (BuiltinServer $process) use ($conn, $sink) { | |
| 21 | +        $this->master->queue->executeAsync(function(BuiltinServer $process) use ($conn, $sink) { | |
| 22 | 22 | $deferred = new Deferred; | 
| 23 | 23 |              try { | 
| 24 | 24 | $child = new Stream($process->getSocketClient(), $this->master->loop); | 
| 25 | 25 | $sink->pipe($child); | 
| 26 | 26 | $child->pipe($conn); | 
| 27 | -                $child->on('close', function () use ($deferred) { | |
| 27 | +                $child->on('close', function() use ($deferred) { | |
| 28 | 28 | $deferred->resolve(); | 
| 29 | 29 | }); | 
| 30 | 30 |              } catch (\RuntimeException $e) { | 
| @@ -12,7 +12,7 @@ discard block | ||
| 12 | 12 |          if (!$processes) { | 
| 13 | 13 |              throw new \LengthException('At least 1 process required.'); | 
| 14 | 14 | } | 
| 15 | -        array_walk($processes, function (BuiltinServer $process) { | |
| 15 | +        array_walk($processes, function(BuiltinServer $process) { | |
| 16 | 16 | $this->processes[spl_object_hash($process)] = $process; | 
| 17 | 17 | }); | 
| 18 | 18 | } | 
| @@ -28,7 +28,7 @@ discard block | ||
| 28 | 28 |      { | 
| 29 | 29 | $process = current($this->processes); | 
| 30 | 30 | unset($this->processes[spl_object_hash($process)]); | 
| 31 | -        $promisor($process)->always(function () use ($process) { | |
| 31 | +        $promisor($process)->always(function() use ($process) { | |
| 32 | 32 | $this->processes[spl_object_hash($process)] = $process; | 
| 33 | 33 | $this->dequeue(); | 
| 34 | 34 | }); | 
| @@ -14,20 +14,20 @@ | ||
| 14 | 14 | public function __construct(ConnectionInterface $src) | 
| 15 | 15 |      { | 
| 16 | 16 | $this->src = $src; | 
| 17 | -        $src->on('data', function ($data) { | |
| 17 | +        $src->on('data', function($data) { | |
| 18 | 18 | $this->buffer .= $data; | 
| 19 | 19 |              if ($this->dst) { | 
| 20 | 20 | $this->dst->write($this->buffer); | 
| 21 | 21 | $this->buffer = ''; | 
| 22 | 22 | } | 
| 23 | 23 | }); | 
| 24 | -        $src->on('end', function () { | |
| 24 | +        $src->on('end', function() { | |
| 25 | 25 | $this->end = true; | 
| 26 | 26 |              if ($this->dst) { | 
| 27 | 27 | $this->dst->end(); | 
| 28 | 28 | } | 
| 29 | 29 | }); | 
| 30 | -        $src->on('error', function () { | |
| 30 | +        $src->on('error', function() { | |
| 31 | 31 | $this->end = true; | 
| 32 | 32 |              if ($this->dst) { | 
| 33 | 33 | $this->dst->end(); |