]>
Commit | Line | Data |
---|---|---|
c0240cb1 | 1 | Related links: |
2 | ||
3 | http://bugs.php.net/bug.php?id=43224 this patch | |
4 | ||
5 | http://bugs.php.net/bug.php?id=41593 | |
6 | http://bugs.php.net/bug.php?id=36158 | |
7 | http://php-fpm.anight.org/ | |
8 | ||
9 | test script too: | |
10 | <?php | |
11 | echo php_sapi_name(), ' running ', PHP_VERSION, "<br>\n"; | |
12 | $i = 0; | |
13 | while ($i < 35) { | |
14 | echo (++$i), "<br>\n"; | |
15 | flush(); | |
16 | sleep(1); | |
17 | } | |
18 | echo "end!<br>\n"; | |
19 | ?> | |
20 | ||
00938eac ER |
21 | --- php-7.0.0beta1/sapi/cgi/cgi_main.c~ 2015-07-13 16:14:53.000000000 +0300 |
22 | +++ php-7.0.0beta1/sapi/cgi/cgi_main.c 2015-07-15 13:51:32.072326529 +0300 | |
c0240cb1 | 23 | @@ -101,6 +101,9 @@ |
24 | */ | |
25 | static int parent = 1; | |
26 | ||
27 | +/* Socket we are listening on incoming connections */ | |
28 | +static int fcgi_fd = 0; | |
29 | + | |
30 | /** | |
31 | * Process group | |
32 | */ | |
33 | @@ -1221,6 +1224,21 @@ | |
34 | exit(0); | |
35 | } | |
36 | ||
37 | +/** | |
38 | + * Graceful shutdown. Close listening sockets. | |
39 | + */ | |
40 | +void fastcgi_graceful_shutdown(int signal) | |
41 | +{ | |
42 | +#ifdef DEBUG_FASTCGI | |
43 | + fprintf(stderr, "FastCGI graceful shutdown, pid %d\n", getpid()); | |
44 | +#endif | |
45 | + | |
46 | + /* Close the listening socket so new processes can reuse the same port */ | |
47 | + closesocket(fcgi_fd); | |
48 | + fcgi_fd = 0; | |
49 | +} | |
50 | + | |
51 | + | |
52 | PHP_INI_BEGIN() | |
53 | STD_PHP_INI_ENTRY("cgi.rfc2616_headers", "0", PHP_INI_ALL, OnUpdateBool, rfc2616_headers, php_cgi_globals_struct, php_cgi_globals) | |
54 | STD_PHP_INI_ENTRY("cgi.nph", "0", PHP_INI_ALL, OnUpdateBool, nph, php_cgi_globals_struct, php_cgi_globals) | |
02d2dcbb | 55 | @@ -1764,7 +1764,6 @@ |
c0240cb1 | 56 | int requests = 0; |
02d2dcbb | 57 | int fastcgi; |
c0240cb1 | 58 | char *bindpath = NULL; |
59 | - int fcgi_fd = 0; | |
02d2dcbb | 60 | fcgi_request *request = NULL; |
c0240cb1 | 61 | int repeats = 1; |
62 | int benchmark = 0; | |
00938eac ER |
63 | @@ -2050,10 +2050,13 @@ |
64 | */ | |
65 | parent = 0; | |
c0240cb1 | 66 | |
00938eac ER |
67 | - /* don't catch our signals */ |
68 | - sigaction(SIGTERM, &old_term, 0); | |
69 | sigaction(SIGQUIT, &old_quit, 0); | |
70 | sigaction(SIGINT, &old_int, 0); | |
c0240cb1 | 71 | + |
00938eac ER |
72 | + /* call graceful shutdown handler for SIGTERM */ |
73 | + act.sa_flags = 0; | |
74 | + act.sa_handler = fastcgi_graceful_shutdown; | |
75 | + sigaction(SIGTERM, &act, &old_term); | |
76 | break; | |
77 | case -1: | |
78 | perror("php (pre-forking)"); |