]> git.pld-linux.org Git - packages/php.git/blob - php-fcgi-graceful.patch
- release 10 (against libltdl-2.2.6-1)
[packages/php.git] / php-fcgi-graceful.patch
1 Related links:
2
3 http://bugs.php.net/bug.php?id=41593
4 http://bugs.php.net/bug.php?id=36158
5 http://php-fpm.anight.org/
6
7 test script too:
8 <?php
9 echo php_sapi_name(), ' running ', PHP_VERSION, "<br>\n";
10 $i = 0;
11 while ($i < 35) {
12     echo (++$i), "<br>\n";
13     flush();
14     sleep(1);
15 }
16 echo "end!<br>\n";
17 ?>
18
19 --- php-5.2.5RC2/sapi/cgi/cgi_main.c    2007-11-01 17:23:14.000000000 +0200
20 +++ php-5.2.5RC2-graceful/sapi/cgi/cgi_main.c   2007-11-08 00:46:38.999355875 +0200
21 @@ -103,6 +103,11 @@
22   */
23  static int parent = 1;
24  
25 +#if PHP_FASTCGI
26 +/* Socket we are listening on incoming FastCGI connections */
27 +static int fcgi_fd = 0;
28 +#endif
29 +
30  /**
31   * Process group
32   */
33 @@ -1157,6 +1162,22 @@
34  }
35  #endif
36  
37 +#if PHP_FASTCGI
38 +/**
39 + * Graceful shutdown. Close listening sockets.
40 + */
41 +void fastcgi_graceful_shutdown(int signal)
42 +{
43 +#ifdef DEBUG_FASTCGI
44 +       fprintf(stderr, "FastCGI graceful shutdown, pid %d\n", getpid());
45 +#endif
46 +
47 +       /* Close the listening socket so new processes can reuse the same port */
48 +       closesocket(fcgi_fd);
49 +       fcgi_fd = 0;
50 +}
51 +#endif
52 +
53  PHP_INI_BEGIN()
54         STD_PHP_INI_ENTRY("cgi.rfc2616_headers",     "0",  PHP_INI_ALL,    OnUpdateBool,   rfc2616_headers, php_cgi_globals_struct, php_cgi_globals)
55         STD_PHP_INI_ENTRY("cgi.nph",                 "0",  PHP_INI_ALL,    OnUpdateBool,   nph, php_cgi_globals_struct, php_cgi_globals)
56 @@ -1275,7 +1296,6 @@
57         int requests = 0;
58         int fastcgi = fcgi_is_fastcgi();
59         char *bindpath = NULL;
60 -       int fcgi_fd = 0;
61         fcgi_request request;
62         int repeats = 1;
63         int benchmark = 0;
64 @@ -1538,9 +1558,17 @@
65                                         parent = 0;
66  
67                                         /* don't catch our signals */
68 -                                       sigaction(SIGTERM, &old_term, 0);
69                                         sigaction(SIGQUIT, &old_quit, 0);
70                                         sigaction(SIGINT,  &old_int,  0);
71 +#if PHP_FASTCGI
72 +
73 +                                       /* call graceful shutdown handler for SIGTERM */
74 +                                       act.sa_flags = 0;
75 +                                       act.sa_handler = fastcgi_graceful_shutdown;
76 +                                       sigaction(SIGTERM, &act, &old_term);
77 +#else
78 +                                       sigaction(SIGTERM, &old_term, 0);
79 +#endif
80                                         break;
81                                 case -1:
82                                         perror("php (pre-forking)");
This page took 0.027582 seconds and 3 git commands to generate.