Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions ext/pcntl/pcntl.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ zend_module_entry pcntl_module_entry = {
"pcntl",
ext_functions,
PHP_MINIT(pcntl),
PHP_MSHUTDOWN(pcntl),
NULL,
PHP_RINIT(pcntl),
PHP_RSHUTDOWN(pcntl),
PHP_MINFO(pcntl),
Expand Down Expand Up @@ -220,11 +220,6 @@ PHP_MINIT_FUNCTION(pcntl)
return SUCCESS;
}

PHP_MSHUTDOWN_FUNCTION(pcntl)
{
return SUCCESS;
}

PHP_RSHUTDOWN_FUNCTION(pcntl)
{
struct php_pcntl_pending_signal *sig;
Expand Down
2 changes: 1 addition & 1 deletion sapi/fpm/fpm/fpm_request.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ void fpm_request_end(void)
fpm_scoreboard_proc_release(proc);

/* memory_peak */
fpm_scoreboard_update_commit(0, 0, 0, 0, 0, 0, 0, proc->memory, FPM_SCOREBOARD_ACTION_SET, NULL);
fpm_scoreboard_update_commit(-1, -1, -1, -1, -1, -1, -1, proc->memory, FPM_SCOREBOARD_ACTION_SET, NULL);
}

void fpm_request_finished(void)
Expand Down
56 changes: 56 additions & 0 deletions sapi/fpm/tests/gh16932-scoreboard-reset.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
--TEST--
FPM: GH-16932 - scoreboard fields are reset after the request
--EXTENSIONS--
pcntl
--SKIPIF--
<?php
include "skipif.inc";
?>
--FILE--
<?php

require_once "tester.inc";

$cfg = <<<EOT
[global]
error_log = {{FILE:LOG}}
pid = {{FILE:PID}}
[unconfined]
listen = {{ADDR}}
pm.status_path = /status
pm = dynamic
pm.max_children = 2
pm.start_servers = 1
pm.min_spare_servers = 1
pm.max_spare_servers = 1
EOT;

$code = <<<EOT
<?php
echo "hi!";
EOT;


$tester = new FPM\Tester($cfg, $code);
$tester->start(extensions: ['pcntl']);
$tester->expectLogStartNotices();
$tester->request();
$tester->request();
$tester->request();
$tester->request();
$tester
->request(uri: '/status', query: 'json')
->expectJsonBodyPatternForStatusField('accepted conn', '5');
$tester->terminate();
$tester->expectLogTerminatingNotices();
$tester->close();

?>
Done
--EXPECT--
Done
--CLEAN--
<?php
require_once "tester.inc";
FPM\Tester::clean();
?>
25 changes: 24 additions & 1 deletion sapi/fpm/tests/response.inc
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,29 @@ class Response extends BaseResponse
return $this;
}

/**
* Expect status field with value that matches the supplied pattern.
*
* @param string $fieldName
* @param string $pattern
*
* @return Response
*/
public function expectJsonBodyPatternForStatusField(string $fieldName, string $pattern): Response
{
$rawData = $this->getBody('application/json');
$data = json_decode($rawData, true);
if (preg_match('|' . $pattern . '|', $data[$fieldName]) > 0) {
return $this;
}

$this->error(
"Field $fieldName did not match pattern $pattern in status data '$rawData'"
);

return $this;
}

/**
* Expect that one of the processes in json status process list has a field with value that
* matches the supplied pattern.
Expand All @@ -167,7 +190,7 @@ class Response extends BaseResponse
);
}
foreach ($data['processes'] as $process) {
if (preg_match('|' . $pattern . '|', $process[$fieldName]) !== false) {
if (preg_match('|' . $pattern . '|', $process[$fieldName]) > 0) {
return $this;
}
}
Expand Down