Bug #77934 [Asn]: php-fpm kill -USR2 not working

From: Date: Sun, 05 May 2019 15:11:43 +0000
Subject: Bug #77934 [Asn]: php-fpm kill -USR2 not working
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-220710@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=77934&edit=1 ID: 77934 Updated by: bukka@php.net Reported by: marc+bugsphp at cdmon dot com Summary: php-fpm kill -USR2 not working Status: Assigned Type: Bug Package: FPM related Operating System: Debian 9 PHP Version: 7.3.4 Assigned To: bukka Block user comment: N Private report: N New Comment: I have been looking to the fpm_signals.c and noticed that we still try to close standard input which might cause this issue. It's done in sig_soft_quit function. So maybe this could fix it: diff --git a/sapi/fpm/fpm/fpm_signals.c b/sapi/fpm/fpm/fpm_signals.c index 1b97025ea7..caf41e8a3f 100644 --- a/sapi/fpm/fpm/fpm_signals.c +++ b/sapi/fpm/fpm/fpm_signals.c @@ -142,7 +142,7 @@ static void sig_soft_quit(int signo) /* {{{ */ int saved_errno = errno; /* closing fastcgi listening socket will force fcgi_accept() exit immediately */ - close(0); + close(fpm_globals.listening_socket); if (0 > socket(AF_UNIX, SOCK_STREAM, 0)) { zlog(ZLOG_WARNING, "failed to create a new socket"); } Previous Comments: ------------------------------------------------------------------------ [2019-04-29 10:06:24] marc+bugsphp at cdmon dot com Dear Jakub, I have tested both patches toghether and it didn't solved the problem. Sorry. ------------------------------------------------------------------------ [2019-04-28 18:21:32] bukka@php.net This is quite interesting that the mentioned fix made things worse for USR2 handling. There are already some errors that could fix it for you too as there are some other issues with USR2 handling. Would you able to test patches from the following bugs?: https://bugs.php.net/bug.php?id=74083 https://bugs.php.net/bug.php?id=76601 There are patches for each bug. I will need to create a test for them before they can be merged but it would be great if they get more testing. ------------------------------------------------------------------------ [2019-04-25 06:37:14] marc+bugsphp at cdmon dot com @Christoph the solution is just a rollback of a previous patch (http://git.php.net/?p=php-src.git;a=commitdiff;h=69dee5c732fe982c82edb17d0dbc3e79a47748d8), as I said I have deleted that patch and it worked. Maybe a workaround for me is just to delete that patch, but it's not the best scenario that I would like. ------------------------------------------------------------------------ [2019-04-24 16:58:03] cmb@php.net Do you mind submitting the patch as pull request[1], to ease review and potential discussion. [1] <https://github.com/php/php-src/pulls> ------------------------------------------------------------------------ [2019-04-24 14:50:03] marc+bugsphp at cdmon dot com I have modified the patch from 7.2.8 that it is this: $ git diff php-7.2.7 php-7.2.8 -- sapi/fpm/fpm/fpm_children.c diff --git a/sapi/fpm/fpm/fpm_children.c b/sapi/fpm/fpm/fpm_children.c index b48fa54f53..4ee316ba1b 100644 --- a/sapi/fpm/fpm/fpm_children.c +++ b/sapi/fpm/fpm/fpm_children.c @@ -146,6 +146,7 @@ static struct fpm_child_s *fpm_child_find(pid_t pid) /* {{{ */ static void fpm_child_init(struct fpm_worker_pool_s *wp) /* {{{ */ { fpm_globals.max_requests = wp->config->pm_max_requests; + fpm_globals.listening_socket = dup(wp->listening_socket); if (0 > fpm_stdio_init_child(wp) || 0 > fpm_log_init_child(wp) || $ git diff php-7.2.7 php-7.2.8 -- sapi/fpm/fpm/fpm_stdio.c diff --git a/sapi/fpm/fpm/fpm_stdio.c b/sapi/fpm/fpm/fpm_stdio.c index 40720176e1..76e8b324df 100644 --- a/sapi/fpm/fpm/fpm_stdio.c +++ b/sapi/fpm/fpm/fpm_stdio.c @@ -103,12 +103,6 @@ int fpm_stdio_init_child(struct fpm_worker_pool_s *wp) /* {{{ */ fpm_globals.error_log_fd = -1; zlog_set_fd(-1); - if (wp->listening_socket != STDIN_FILENO) { - if (0 > dup2(wp->listening_socket, STDIN_FILENO)) { - zlog(ZLOG_SYSERROR, "failed to init child stdio: dup2()"); - return -1; - } - } return 0; } /* }}} */ and it worked as spected, restarting the childrens at moment of doing kill -USR2 PID. I need to add to this, that I'm using a 0 request server, is a test server to just test this bug. Thanks. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=77934 -- Edit this bug report at https://bugs.php.net/bug.php?id=77934&edit=1

« previous php.bugs (#220710) next »