Skip to content

Commit

Permalink
Skip cli_set_process_title inside phpdbg
Browse files Browse the repository at this point in the history
  • Loading branch information
kelunik committed Jun 17, 2017
1 parent 39664d4 commit 4546ef8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
11 changes: 7 additions & 4 deletions bin/worker
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
use Amp\Parallel\Sync;
use Amp\Parallel\Worker;

@cli_set_process_title('amp-worker');
// Doesn't exist in phpdbg...
if (\function_exists('cli_set_process_title')) {
@cli_set_process_title('amp-worker');
}

// Redirect all output written using echo, print, printf, etc. to STDERR.
ob_start(function ($data) {
Expand All @@ -17,20 +20,20 @@ ob_start(function ($data) {
dirname(__DIR__, 3) . '/autoload.php',
dirname(__DIR__) . '/vendor/autoload.php',
];

$autoloadPath = null;
foreach ($paths as $path) {
if (file_exists($path)) {
$autoloadPath = $path;
break;
}
}

if ($autoloadPath === null) {
fwrite(STDERR, 'Could not locate autoload.php.');
exit(1);
}

require $autoloadPath;
})();

Expand Down
5 changes: 3 additions & 2 deletions lib/Sync/ChannelParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,11 @@ public function encode($data): string {
*/
private static function parser(callable $callback, callable $errorHandler): \Generator {
while (true) {
$data = \unpack("Cprefix/Llength", yield self::HEADER_LENGTH);
$header = yield self::HEADER_LENGTH;
$data = \unpack("Cprefix/Llength", $header);

if ($data["prefix"] !== 0) {
throw new ChannelException("Invalid header received");
throw new ChannelException("Invalid header received: " . \bin2hex($header));
}

$data = yield $data["length"];
Expand Down

0 comments on commit 4546ef8

Please sign in to comment.