mirror of
https://github.com/php/php-src.git
synced 2026-03-29 03:32:20 +02:00
https://bugs.php.net/bug.php?id=74166 A host system with no/limited IPv6 support will fail at binding the IPv6 ANYADDR address (::) as the address family is unsupported. Deal with this by handling failure to implicitly bind to :: as a soft failure, falling back to 0.0.0.0. If binding to :: failed for some other reason (e.g. port in use) then binding to 0.0.0.0 will likely fail as well, but we'll get appropriate warnings for that.
58 lines
1.4 KiB
PHP
58 lines
1.4 KiB
PHP
--TEST--
|
|
FPM: Test already bound address
|
|
--SKIPIF--
|
|
<?php include "skipif.inc"; ?>
|
|
--FILE--
|
|
<?php
|
|
|
|
include "include.inc";
|
|
|
|
$logfile = dirname(__FILE__).'/php-fpm.log.tmp';
|
|
$port = 9000+PHP_INT_SIZE;
|
|
|
|
$cfg = <<<EOT
|
|
[global]
|
|
log_level = debug
|
|
error_log = $logfile
|
|
[unconfined]
|
|
listen = $port
|
|
ping.path = /ping
|
|
ping.response = pong
|
|
pm = dynamic
|
|
pm.max_children = 5
|
|
pm.start_servers = 2
|
|
pm.min_spare_servers = 1
|
|
pm.max_spare_servers = 3
|
|
EOT;
|
|
|
|
// Occupy our port and let things fail
|
|
$busy = stream_socket_server("tcp://[::]:$port");
|
|
|
|
$fpm = run_fpm($cfg, $tail);
|
|
if (is_resource($fpm)) {
|
|
/* Expect two specific lines of log output and show them
|
|
* If we get any different number of those patterns, display whole log
|
|
*/
|
|
$out = $all = '';
|
|
$count = 0;
|
|
while (!feof($tail)) {
|
|
$line = fgets($tail);
|
|
$all .= $line;
|
|
if ((false !== strpos($line, 'retrying with 0.0.0.0')) ||
|
|
(false !== strpos($line, 'unable to bind'))) {
|
|
$out .= $line;
|
|
++$count;
|
|
}
|
|
}
|
|
echo ($count == 2) ? $out : $all;
|
|
}
|
|
?>
|
|
--EXPECTF--
|
|
[%d-%s-%d %d:%d:%f] NOTICE: pid %d, fpm_socket_af_inet_listening_socket(), line %d: Failed implicitly binding to ::, retrying with 0.0.0.0
|
|
[%d-%s-%d %d:%d:%f] ERROR: pid %d, fpm_sockets_new_listening_socket(), line %d: unable to bind listening socket for address '%d': %s
|
|
--CLEAN--
|
|
<?php
|
|
$logfile = dirname(__FILE__).'/php-fpm.log.tmp';
|
|
@unlink($logfile);
|
|
?>
|