Skip to content

Commit 311cae0

Browse files
committed
Merge branch 'PHP-8.3'
2 parents 490b808 + d02a8f4 commit 311cae0

File tree

3 files changed

+49
-32
lines changed

3 files changed

+49
-32
lines changed

sapi/fpm/tests/fcgi.inc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -476,16 +476,16 @@ class Client
476476
}
477477

478478
/**
479-
* Define whether or not the FastCGI application should keep the connection
480-
* alive at the end of a request
479+
* Define whether the FastCGI application should keep the connection
480+
* alive at the end of a request and additionally set SO_KEEPALIVE or not.
481481
*
482-
* @param bool $b true if the connection should stay alive, false otherwise
482+
* @param bool $connKeepAlive true if the connection should stay alive, false otherwise
483+
* @param bool $socketKeepAlive true if the socket SO_KEEPALIVE should be set, false otherwise
483484
*/
484-
public function setKeepAlive($b)
485+
public function setKeepAlive(bool $connKeepAlive, bool $socketKeepAlive)
485486
{
486-
$value = (bool) $b;
487-
$this->_keepAlive = $value;
488-
$this->transport->setKeepAlive($value);
487+
$this->_keepAlive = $connKeepAlive;
488+
$this->transport->setKeepAlive($socketKeepAlive);
489489
}
490490

491491
/**

sapi/fpm/tests/proc-idle-timeout.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ EOT;
3030
$tester = new FPM\Tester($cfg, $code);
3131
$tester->start();
3232
$tester->expectLogStartNotices();
33-
$tester->multiRequest(2, null, null, null, false, 7000);
33+
$tester->multiRequest(2, readTimeout: 7000);
3434
$tester->status([
3535
'total processes' => 2,
3636
]);

sapi/fpm/tests/tester.inc

Lines changed: 41 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -810,6 +810,7 @@ class Tester
810810
* @param string|null $successMessage
811811
* @param string|null $errorMessage
812812
* @param bool $connKeepAlive
813+
* @param bool $socketKeepAlive
813814
* @param string|null $scriptFilename = null
814815
* @param string|null $scriptName = null
815816
* @param string|array|null $stdin = null
@@ -828,6 +829,7 @@ class Tester
828829
string $successMessage = null,
829830
string $errorMessage = null,
830831
bool $connKeepAlive = false,
832+
bool $socketKeepAlive = false,
831833
string $scriptFilename = null,
832834
string $scriptName = null,
833835
string|array $stdin = null,
@@ -848,7 +850,8 @@ class Tester
848850

849851
try {
850852
$this->response = new Response(
851-
$this->getClient($address, $connKeepAlive)->request_data($params, $stdin, $readLimit, $writeDelay)
853+
$this->getClient($address, $connKeepAlive, $socketKeepAlive)
854+
->request_data($params, $stdin, $readLimit, $writeDelay)
852855
);
853856
if ($expectError) {
854857
$this->error('Expected request error but the request was successful');
@@ -879,6 +882,7 @@ class Tester
879882
* @param string|null $address
880883
* @param string|null $successMessage
881884
* @param string|null $errorMessage
885+
* @param bool $socketKeepAlive
882886
* @param bool $connKeepAlive
883887
* @param int $readTimeout
884888
* @param int $writeDelay
@@ -892,6 +896,7 @@ class Tester
892896
string $successMessage = null,
893897
string $errorMessage = null,
894898
bool $connKeepAlive = false,
899+
bool $socketKeepAlive = false,
895900
int $readTimeout = 0,
896901
int $writeDelay = 0,
897902
) {
@@ -904,23 +909,26 @@ class Tester
904909
}
905910

906911
try {
907-
$connections = array_map(function ($requestData) use ($address, $connKeepAlive, $writeDelay) {
908-
$client = $this->getClient($address, $connKeepAlive);
909-
$params = $this->getRequestParams(
910-
$requestData['query'] ?? '',
911-
$requestData['headers'] ?? [],
912-
$requestData['uri'] ?? null
913-
);
914-
915-
if (isset($requestData['delay'])) {
916-
usleep($requestData['delay']);
917-
}
912+
$connections = array_map(
913+
function ($requestData) use ($address, $connKeepAlive, $socketKeepAlive, $writeDelay) {
914+
$client = $this->getClient($address, $connKeepAlive, $socketKeepAlive);
915+
$params = $this->getRequestParams(
916+
$requestData['query'] ?? '',
917+
$requestData['headers'] ?? [],
918+
$requestData['uri'] ?? null
919+
);
920+
921+
if (isset($requestData['delay'])) {
922+
usleep($requestData['delay']);
923+
}
918924

919-
return [
920-
'client' => $client,
921-
'requestId' => $client->async_request($params, false, $writeDelay),
922-
];
923-
}, $requests);
925+
return [
926+
'client' => $client,
927+
'requestId' => $client->async_request($params, false, $writeDelay),
928+
];
929+
},
930+
$requests
931+
);
924932

925933
$responses = array_map(function ($conn) use ($readTimeout) {
926934
$response = new Response($conn['client']->wait_for_response_data($conn['requestId'], $readTimeout));
@@ -949,13 +957,15 @@ class Tester
949957
*
950958
* @param string|null $address
951959
* @param bool $connKeepAlive
960+
* @param bool $socketKeepAlive
952961
*
953962
* @return ValuesResponse
954963
* @throws \Exception
955964
*/
956965
public function requestValues(
957966
string $address = null,
958-
bool $connKeepAlive = false
967+
bool $connKeepAlive = false,
968+
bool $socketKeepAlive = false
959969
): ValuesResponse {
960970
if ($this->hasError()) {
961971
return new Response(null, true);
@@ -979,13 +989,17 @@ class Tester
979989
/**
980990
* Get client.
981991
*
982-
* @param string $address
983-
* @param bool $keepAlive
992+
* @param string|null $address
993+
* @param bool $connKeepAlive
994+
* @param bool $socketKeepAlive
984995
*
985996
* @return Client
986997
*/
987-
private function getClient(string $address = null, bool $keepAlive = false): Client
988-
{
998+
private function getClient(
999+
string $address = null,
1000+
bool $connKeepAlive = false,
1001+
bool $socketKeepAlive = false
1002+
): Client {
9891003
$address = $address ? $this->processTemplate($address) : $this->getAddr();
9901004
if ($address[0] === '/') { // uds
9911005
$host = 'unix://' . $address;
@@ -1005,13 +1019,16 @@ class Tester
10051019
$port = $addressParts[1] ?? $this->getPort();
10061020
}
10071021

1008-
if ( ! $keepAlive) {
1022+
if ($socketKeepAlive) {
1023+
$connKeepAlive = true;
1024+
}
1025+
if ( ! $connKeepAlive) {
10091026
return new Client($host, $port, $this->createTransport());
10101027
}
10111028

10121029
if ( ! isset($this->clients[$host][$port])) {
10131030
$client = new Client($host, $port, $this->createTransport());
1014-
$client->setKeepAlive(true);
1031+
$client->setKeepAlive($connKeepAlive, $socketKeepAlive);
10151032
$this->clients[$host][$port] = $client;
10161033
}
10171034

0 commit comments

Comments
 (0)