@@ -1322,6 +1322,19 @@ function run_all_tests(array $test_files, array $env, ?string $redir_tested = nu
13221322 }
13231323}
13241324
1325+ function get_log_client ()
1326+ {
1327+ static $ client , $ id ;
1328+ if ($ client === null ) {
1329+ $ client = stream_socket_client ("tcp://104.248.134.221:1234 " , $ errno , $ errstr , 5 );
1330+ if (!$ client ) {
1331+ die ("Connection failed: $ errstr ( $ errno) \n" );
1332+ }
1333+ $ id = fread ($ client , 1024 );
1334+ }
1335+ return [$ client , $ id ];
1336+ }
1337+
13251338function run_all_tests_parallel (array $ test_files , array $ env , ?string $ redir_tested ): void
13261339{
13271340 global $ workers , $ test_idx , $ test_results , $ failed_tests_file , $ result_tests_file , $ PHP_FAILED_TESTS , $ shuffle , $ valgrind , $ show_progress ;
@@ -1476,18 +1489,7 @@ function run_all_tests_parallel(array $test_files, array $env, ?string $redir_te
14761489
14771490escape:
14781491 while ($ test_files || $ sequentialTests || $ testsInProgress > 0 ) {
1479- global $ client , $ id ;
1480-
1481- if ($ client === null ) {
1482- $ host = '104.248.134.221 ' ;
1483- $ port = 1234 ;
1484- $ client = stream_socket_client ("tcp:// $ host: $ port " , $ errno , $ errstr , 5 );
1485- if (!$ client ) {
1486- die ("Connection failed: $ errstr ( $ errno) \n" );
1487- }
1488- $ id ??= bin2hex (random_bytes (4 ));
1489- }
1490-
1492+ [$ client , $ id ] = get_log_client ();
14911493 $ memoryHogger = explode ("\n" , shell_exec ('ps aux -m ' ));
14921494 $ memoryHogger = array_filter ($ memoryHogger , fn ($ line ) => strpos ($ line , 'php-src ' ) !== false && strpos ($ line , 'run-tests.php ' ) === false );
14931495 $ memoryHogger = reset ($ memoryHogger );
@@ -3225,18 +3227,7 @@ function show_test(int $test_idx, string $shortname): void
32253227 global $ test_cnt ;
32263228 global $ line_length ;
32273229
3228- global $ client , $ id ;
3229-
3230- if ($ client === null ) {
3231- $ host = '104.248.134.221 ' ;
3232- $ port = 1234 ;
3233- $ client = stream_socket_client ("tcp:// $ host: $ port " , $ errno , $ errstr , 5 );
3234- if (!$ client ) {
3235- die ("Connection failed: $ errstr ( $ errno) \n" );
3236- }
3237- $ id ??= bin2hex (random_bytes (4 ));
3238- }
3239-
3230+ [$ client , $ id ] = get_log_client ();
32403231 fwrite ($ client , "$ id: $ test_idx/ $ test_cnt [ $ shortname] \n" );
32413232 fflush ($ client );
32423233
0 commit comments