Skip to content

Commit

Permalink
Parallel analysis - attempt to fix UTF-8 error
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Nov 16, 2020
1 parent 8283c71 commit 0524fb5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/Command/FixerApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ public function log(string $message): void
);

$server->on('connection', function (ConnectionInterface $connection) use ($loop, $projectConfigFile, $input, $output, $fileSpecificErrors, $notFileSpecificErrors, $mainScript, $filesCount, $reanalyseProcessQueue, $inceptionResult): void {
$decoder = new Decoder($connection, true, 512, 0, 128 * 1024 * 1024);
$encoder = new Encoder($connection);
$decoder = new Decoder($connection, true, 512, defined('JSON_INVALID_UTF8_IGNORE') ? JSON_INVALID_UTF8_IGNORE : 0, 128 * 1024 * 1024);
$encoder = new Encoder($connection, defined('JSON_INVALID_UTF8_IGNORE') ? JSON_INVALID_UTF8_IGNORE : 0);
$encoder->write(['action' => 'initialData', 'data' => [
'fileSpecificErrors' => $fileSpecificErrors,
'notFileSpecificErrors' => $notFileSpecificErrors,
Expand Down
4 changes: 2 additions & 2 deletions src/Command/WorkerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int

$tcpConector = new TcpConnector($loop);
$tcpConector->connect(sprintf('127.0.0.1:%d', $port))->done(function (ConnectionInterface $connection) use ($container, $identifier, $output, $analysedFiles, $tmpFile, $insteadOfFile): void {
$out = new Encoder($connection);
$in = new Decoder($connection, true, 512, 0, $container->getParameter('parallel')['buffer']);
$out = new Encoder($connection, defined('JSON_INVALID_UTF8_IGNORE') ? JSON_INVALID_UTF8_IGNORE : 0);
$in = new Decoder($connection, true, 512, defined('JSON_INVALID_UTF8_IGNORE') ? JSON_INVALID_UTF8_IGNORE : 0, $container->getParameter('parallel')['buffer']);
$out->write(['action' => 'hello', 'identifier' => $identifier]);
$this->runWorker($container, $out, $in, $output, $analysedFiles, $tmpFile, $insteadOfFile);
});
Expand Down
4 changes: 2 additions & 2 deletions src/Parallel/ParallelAnalyser.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ public function analyse(
$server = new \React\Socket\TcpServer('127.0.0.1:0', $loop);
$this->processPool = new ProcessPool($server);
$server->on('connection', function (ConnectionInterface $connection) use (&$jobs): void {
$decoder = new Decoder($connection, true, 512, 0, $this->decoderBufferSize);
$encoder = new Encoder($connection);
$decoder = new Decoder($connection, true, 512, defined('JSON_INVALID_UTF8_IGNORE') ? JSON_INVALID_UTF8_IGNORE : 0, $this->decoderBufferSize);
$encoder = new Encoder($connection, defined('JSON_INVALID_UTF8_IGNORE') ? JSON_INVALID_UTF8_IGNORE : 0);
$decoder->on('data', function (array $data) use (&$jobs, $decoder, $encoder): void {
if ($data['action'] !== 'hello') {
return;
Expand Down

0 comments on commit 0524fb5

Please sign in to comment.