From 909d44f20dd00ccf3a6519707bfaba2ed30e8b2b Mon Sep 17 00:00:00 2001 From: David Zuelke Date: Sat, 8 Nov 2014 20:18:58 -0500 Subject: [PATCH 1/7] Change pm.start_servers default warning to notice Unlike other settings, this has a perfectly reasonable default, calculated using a dynamic formula. If the default was hardcoded to "2" or something, then it would make sense to have a warning, since that could potentially be bad, but for a dynamically calculated value based on other mandatory settings, a notice ought to be enough. --- sapi/fpm/fpm/fpm_conf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sapi/fpm/fpm/fpm_conf.c b/sapi/fpm/fpm/fpm_conf.c index 34e0480101a..ce37b3cfc83 100644 --- a/sapi/fpm/fpm/fpm_conf.c +++ b/sapi/fpm/fpm/fpm_conf.c @@ -819,7 +819,7 @@ static int fpm_conf_process_all_pools() /* {{{ */ if (config->pm_start_servers <= 0) { config->pm_start_servers = config->pm_min_spare_servers + ((config->pm_max_spare_servers - config->pm_min_spare_servers) / 2); - zlog(ZLOG_WARNING, "[pool %s] pm.start_servers is not set. It's been set to %d.", wp->config->name, config->pm_start_servers); + zlog(ZLOG_NOTICE, "[pool %s] pm.start_servers is not set. It's been set to %d.", wp->config->name, config->pm_start_servers); } else if (config->pm_start_servers < config->pm_min_spare_servers || config->pm_start_servers > config->pm_max_spare_servers) { zlog(ZLOG_ALERT, "[pool %s] pm.start_servers(%d) must not be less than pm.min_spare_servers(%d) and not greater than pm.max_spare_servers(%d)", wp->config->name, config->pm_start_servers, config->pm_min_spare_servers, config->pm_max_spare_servers); From befce20c84527181f760fb53e4d536f22e84953e Mon Sep 17 00:00:00 2001 From: David Zuelke Date: Wed, 19 Nov 2014 23:39:00 +0100 Subject: [PATCH 2/7] move zlog_set_level() again from fpm_unix_init_main() to fpm_conf_post_process() this time (see #894), because otherwise nothing in fpm_conf_init_main() obeys log levels --- sapi/fpm/fpm/fpm_conf.c | 1 + sapi/fpm/fpm/fpm_unix.c | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/sapi/fpm/fpm/fpm_conf.c b/sapi/fpm/fpm/fpm_conf.c index ce37b3cfc83..26a9fd1c7a5 100644 --- a/sapi/fpm/fpm/fpm_conf.c +++ b/sapi/fpm/fpm/fpm_conf.c @@ -1159,6 +1159,7 @@ static int fpm_conf_post_process(int force_daemon TSRMLS_DC) /* {{{ */ } fpm_globals.log_level = fpm_global_config.log_level; + zlog_set_level(fpm_globals.log_level); if (fpm_global_config.process_max < 0) { zlog(ZLOG_ERROR, "process_max can't be negative"); diff --git a/sapi/fpm/fpm/fpm_unix.c b/sapi/fpm/fpm/fpm_unix.c index c29e28f8867..32448fc4d5d 100644 --- a/sapi/fpm/fpm/fpm_unix.c +++ b/sapi/fpm/fpm/fpm_unix.c @@ -266,8 +266,6 @@ int fpm_unix_init_main() /* {{{ */ struct fpm_worker_pool_s *wp; int is_root = !geteuid(); - zlog_set_level(fpm_globals.log_level); - if (fpm_global_config.rlimit_files) { struct rlimit r; From 49be4af42bdb4ae013cfd5a9739c1639056b7e12 Mon Sep 17 00:00:00 2001 From: David Zuelke Date: Wed, 19 Nov 2014 23:40:03 +0100 Subject: [PATCH 3/7] tests for #895 --- sapi/fpm/tests/014.phpt | 54 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 sapi/fpm/tests/014.phpt diff --git a/sapi/fpm/tests/014.phpt b/sapi/fpm/tests/014.phpt new file mode 100644 index 00000000000..d6a8f250b78 --- /dev/null +++ b/sapi/fpm/tests/014.phpt @@ -0,0 +1,54 @@ +--TEST-- +FPM: Test for pm.start_servers notice #... +--SKIPIF-- + +--FILE-- + +Done +--EXPECTF-- +Started +Done +--CLEAN-- + \ No newline at end of file From a128cbad578adbb2ca16ae84c8b2fef609067c8d Mon Sep 17 00:00:00 2001 From: David Zuelke Date: Wed, 19 Nov 2014 23:46:22 +0100 Subject: [PATCH 4/7] fix test description --- sapi/fpm/tests/014.phpt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sapi/fpm/tests/014.phpt b/sapi/fpm/tests/014.phpt index d6a8f250b78..ee0e549cc57 100644 --- a/sapi/fpm/tests/014.phpt +++ b/sapi/fpm/tests/014.phpt @@ -1,5 +1,5 @@ --TEST-- -FPM: Test for pm.start_servers notice #... +FPM: Test for pm.start_servers default calculation message being a notice and not a warning #68458 --SKIPIF-- --FILE-- From 1939097ededdbf1d42305e32f6a9947ff6a7e91f Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Thu, 20 Nov 2014 08:12:27 +0100 Subject: [PATCH 5/7] Fixed #68458 Change pm.start_servers default warning to notice Add another test 014 checks that no "notice" are traced when log_level=warning 015 checks that "notice" are traced when log_level=notice --- sapi/fpm/tests/015.phpt | 64 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 sapi/fpm/tests/015.phpt diff --git a/sapi/fpm/tests/015.phpt b/sapi/fpm/tests/015.phpt new file mode 100644 index 00000000000..00e8bf3f5f2 --- /dev/null +++ b/sapi/fpm/tests/015.phpt @@ -0,0 +1,64 @@ +--TEST-- +FPM: Test various messages on start, from master and childs +--SKIPIF-- + +--FILE-- + +Done +--EXPECTF-- +Started +[%s] NOTICE: [pool unconfined] pm.start_servers is not set. It's been set to 2. +[%s] NOTICE: [pool unconfined] 'user' directive is ignored when FPM is not running as root +[%s] NOTICE: fpm is running, pid %d +[%s] NOTICE: ready to handle connections +[%s] WARNING: [pool unconfined] child %d said into stderr: "ERROR: Wrong IP address 'xxx' in listen.allowed_clients" +[%s] WARNING: [pool unconfined] child %d said into stderr: "ERROR: Wrong IP address 'xxx' in listen.allowed_clients" +[%s] NOTICE: Terminating ... +[%s] NOTICE: exiting, bye-bye! +Done +--CLEAN-- + \ No newline at end of file From 914787491d78cded722318d0796b13f11cb197f8 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Thu, 20 Nov 2014 08:15:13 +0100 Subject: [PATCH 6/7] NEWS --- NEWS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS b/NEWS index cf148e5e5fa..25966854e6b 100644 --- a/NEWS +++ b/NEWS @@ -18,6 +18,8 @@ PHP NEWS . Fixed bug #68381 (fpm_unix_init_main ignores log_level). (David Zuelke, Remi) . Fixed bug #68452 (php-fpm man page is oudated). (Remi) + . Fixed request #68458 (Change pm.start_servers default warning to + notice). (David Zuelke, Remi) GMP: . Fixed bug #68419 (build error with gmp 4.1). (Remi) From 9fd54bd9d8f20f4d56c3d8e0209c6c34fb3bfc98 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Thu, 20 Nov 2014 10:15:15 +0100 Subject: [PATCH 7/7] Raise a warning when listen = hostname used and is resolved as multiple addresses Using getaddrinfo is perhaps not a good idea... if we are not able to listen on multiple addresses... At least this message should help to diagnose problem, ex ... Found address for localhost, socket opened on ::1 ... Found multiple addresses for localhost, 127.0.0.1 ignored --- sapi/fpm/fpm/fpm_sockets.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/sapi/fpm/fpm/fpm_sockets.c b/sapi/fpm/fpm/fpm_sockets.c index 9d9def35c7c..0286f0eee8d 100644 --- a/sapi/fpm/fpm/fpm_sockets.c +++ b/sapi/fpm/fpm/fpm_sockets.c @@ -255,6 +255,7 @@ static int fpm_socket_af_inet_listening_socket(struct fpm_worker_pool_s *wp) /* char *dup_address = strdup(wp->config->listen_address); char *port_str = strrchr(dup_address, ':'); char *addr = NULL; + char tmpbuf[INET6_ADDRSTRLEN]; int addr_len; int port = 0; int sock = -1; @@ -302,14 +303,18 @@ static int fpm_socket_af_inet_listening_socket(struct fpm_worker_pool_s *wp) /* return -1; } - free(dup_address); - for (p = servinfo; p != NULL; p = p->ai_next) { - if ((sock = fpm_sockets_get_listening_socket(wp, p->ai_addr, p->ai_addrlen)) != -1) { - break; + inet_ntop(p->ai_family, fpm_get_in_addr(p->ai_addr), tmpbuf, INET6_ADDRSTRLEN); + if (sock < 0) { + if ((sock = fpm_sockets_get_listening_socket(wp, p->ai_addr, p->ai_addrlen)) != -1) { + zlog(ZLOG_DEBUG, "Found address for %s, socket opened on %s", dup_address, tmpbuf); + } + } else { + zlog(ZLOG_WARNING, "Found multiple addresses for %s, %s ignored", dup_address, tmpbuf); } } + free(dup_address); freeaddrinfo(servinfo); return sock;