@@ -24,21 +24,31 @@ pm.status_path = /status
24
24
env[PATH] = $PATH
25
25
EOT;
26
26
27
-
28
27
$ code = <<<'EOT'
29
28
<?php
30
29
31
- echo "My sockets (expect to see 2 of them):\n";
30
+ $fpmPort = $_GET['fpm_port'];
31
+
32
+ echo "My sockets (expect to see 2 of them - one ESTABLISHED and one LISTEN):\n";
32
33
33
34
$mypid = getmypid();
34
- $ph = popen("/bin/sh -c 'lsof -Pn -p$mypid' 2>&1 | grep TCP", 'r');
35
+ $ph = popen("/bin/sh -c 'lsof -Pn -p$mypid' 2>&1 | grep TCP | grep '127.0.0.1:$fpmPort' ", 'r');
35
36
echo stream_get_contents($ph);
36
37
pclose($ph);
37
38
38
39
echo "\n\n";
39
40
41
+ /*
42
+ We expect that both LISTEN (inherited from the master process) and ACCEPTED (ESTABLISHED)
43
+ have F_CLOEXEC and should not appear in the created process.
44
+
45
+ We grep out sockets from non-FPM port, because they may appear in the environment,
46
+ e.g. PHP-FPM can inherit them from the test-runner. We cannot control the runner
47
+ but we test how the FPM behaves.
48
+ */
49
+
40
50
echo "Sockets after exec(), expected to be empty:\n";
41
- $ph = popen("/bin/sh -c 'lsof -Pn -p\$\$' 2>&1 | grep TCP", 'r');
51
+ $ph = popen("/bin/sh -c 'lsof -Pn -p\$\$' 2>&1 | grep TCP | grep '127.0.0.1:$fpmPort' ", 'r');
42
52
var_dump(stream_get_contents($ph));
43
53
pclose($ph);
44
54
47
57
$ tester = new FPM \Tester ($ cfg , $ code );
48
58
$ tester ->start ();
49
59
$ tester ->expectLogStartNotices ();
50
- $ tester ->request ()->printBody ();
60
+ $ tester ->request (query: ' fpm_port= ' . $ tester -> getPort () )->printBody ();
51
61
usleep (100000 );
52
62
//$tester->status($expectedStatusData, '{{ADDR[status]}}');
53
63
$ tester ->terminate ();
@@ -57,7 +67,9 @@ $tester->close();
57
67
?>
58
68
Done
59
69
--EXPECTF--
60
- My sockets (expect to see 2 of them):
70
+ My sockets (expect to see 2 of them - one ESTABLISHED and one LISTEN):
71
+ %S 127.0.0.1:%d->127.0.0.1:%d (ESTABLISHED)
72
+ %S 127.0.0.1:%d (LISTEN)
61
73
62
74
63
75
Sockets after exec(), expected to be empty:
0 commit comments