Description
When I run the following script as a POST request with parallel version 1.2.3 or later the script hangs or crashes (I get 502 gateway timeout from nginx):
use \parallel\{Runtime};
$test_func = function($test_string)
{
sleep(1);
return 'Test ' . $test_string . "<br>\n";
};
$future_a = \parallel\run($test_func, ['A']);
$future_b = \parallel\run($test_func, ['B']);
$future_c = \parallel\run($test_func, ['C']);
echo $future_a->value();
echo $future_b->value();
echo $future_c->value();
When I run the script as a GET request, the script finishes without error. If the POST request contains empty body, the script finishes without error. When I modify the source code of the parallel extension and recompile, the POST problem disappears.
The modification that eliminates the error is basically reverting the Github commit 7e02ef0:
ver 1.2.3, file scheduler.c, comment out the line 86 like this:
// SG(request_info) = *runtime->parent.request_info;
ver 1.2.3, file scheduler.c, comment out the line 103 like this:
// SG(request_info).no_headers = 1;
ver 1.2.3, file runtime.c, comment out the line 131 like this:
// runtime->parent.request_info = &SG(request_info);
PHP is run as PHP FPM with nginx via FCGI
PHP 8.2.28 compiled from source, parallel compiled in:
./configure --enable-fpm --enable-parallel --with-mysql --with-zlib --enable-gd --with-freetype --with-jpeg --with-webp --enable-mbstring --enable-ftp --with-openssl --with-imap --with-imap-ssl --with-kerberos --enable-opcache --with-mysqli --with-mysql-sock --enable-soap --with-zip --enable-zts --disable-ipv6 --enable-sysvsem --enable-sysvshm --enable-sysvmsg --enable-sockets
nginx config file:
location ~ .php$
{
fastcgi_pass unix:/var/run/php.www1.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www$fastcgi_script_name;
include fastcgi_params;
}
file fastcgi_params:
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REQUEST_SCHEME $scheme;
fastcgi_param HTTPS $https if_not_empty;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param REDIRECT_STATUS 200;