summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOleg Efimov <o.efimov@corp.badoo.com>2016-09-06 12:27:57 +0300
committerOleg Efimov <o.efimov@corp.badoo.com>2016-09-06 12:27:57 +0300
commitba65b37b262bd44334fefc1f4354cddb1bd008d5 (patch)
tree73771b953ce059712aa98239b022ddcf7bff55db
parent5ac49731cf149e75e243d57784189b82da08885e (diff)
downloadphp-git-ba65b37b262bd44334fefc1f4354cddb1bd008d5.tar.gz
Allow to configure php-fpm slow log trace callers limit
-rw-r--r--sapi/fpm/fpm/fpm_conf.c26
-rw-r--r--sapi/fpm/fpm/fpm_conf.h1
-rw-r--r--sapi/fpm/fpm/fpm_php_trace.c2
-rw-r--r--sapi/fpm/www.conf.in4
4 files changed, 32 insertions, 1 deletions
diff --git a/sapi/fpm/fpm/fpm_conf.c b/sapi/fpm/fpm/fpm_conf.c
index b497d2c82c..c9a946155a 100644
--- a/sapi/fpm/fpm/fpm_conf.c
+++ b/sapi/fpm/fpm/fpm_conf.c
@@ -146,6 +146,7 @@ static struct ini_value_parser_s ini_fpm_pool_options[] = {
{ "access.format", &fpm_conf_set_string, WPO(access_format) },
{ "slowlog", &fpm_conf_set_string, WPO(slowlog) },
{ "request_slowlog_timeout", &fpm_conf_set_time, WPO(request_slowlog_timeout) },
+ { "request_slowlog_trace_depth", &fpm_conf_set_integer, WPO(request_slowlog_trace_depth) },
{ "request_terminate_timeout", &fpm_conf_set_time, WPO(request_terminate_timeout) },
{ "rlimit_files", &fpm_conf_set_integer, WPO(rlimit_files) },
{ "rlimit_core", &fpm_conf_set_rlimit_core, WPO(rlimit_core) },
@@ -970,6 +971,30 @@ static int fpm_conf_process_all_pools() /* {{{ */
}
}
+ /* request_slowlog_trace_depth */
+ if (wp->config->request_slowlog_trace_depth) {
+#if HAVE_FPM_TRACE
+ if (! (wp->config->slowlog && *wp->config->slowlog)) {
+ zlog(ZLOG_ERROR, "[pool %s] 'slowlog' must be specified for use with 'request_slowlog_trace_depth'", wp->config->name);
+ return -1;
+ }
+#else
+ static int warned = 0;
+
+ if (!warned) {
+ zlog(ZLOG_WARNING, "[pool %s] 'request_slowlog_trace_depth' is not supported on your system", wp->config->name);
+ warned = 1;
+ }
+#endif
+
+ if (wp->config->request_slowlog_trace_depth <= 0) {
+ zlog(ZLOG_ERROR, "[pool %s] 'request_slowlog_trace_depth' (%d) must be a positive value", wp->config->name, wp->config->request_slowlog_trace_depth);
+ return -1;
+ }
+ } else {
+ wp->config->request_slowlog_trace_depth = 20;
+ }
+
/* chroot */
if (wp->config->chroot && *wp->config->chroot) {
@@ -1635,6 +1660,7 @@ static void fpm_conf_dump() /* {{{ */
zlog(ZLOG_NOTICE, "\taccess.format = %s", STR2STR(wp->config->access_format));
zlog(ZLOG_NOTICE, "\tslowlog = %s", STR2STR(wp->config->slowlog));
zlog(ZLOG_NOTICE, "\trequest_slowlog_timeout = %ds", wp->config->request_slowlog_timeout);
+ zlog(ZLOG_NOTICE, "\trequest_slowlog_trace_depth = %d", wp->config->request_slowlog_trace_depth);
zlog(ZLOG_NOTICE, "\trequest_terminate_timeout = %ds", wp->config->request_terminate_timeout);
zlog(ZLOG_NOTICE, "\trlimit_files = %d", wp->config->rlimit_files);
zlog(ZLOG_NOTICE, "\trlimit_core = %d", wp->config->rlimit_core);
diff --git a/sapi/fpm/fpm/fpm_conf.h b/sapi/fpm/fpm/fpm_conf.h
index 540b22795d..d56fcc4e78 100644
--- a/sapi/fpm/fpm/fpm_conf.h
+++ b/sapi/fpm/fpm/fpm_conf.h
@@ -78,6 +78,7 @@ struct fpm_worker_pool_config_s {
char *access_format;
char *slowlog;
int request_slowlog_timeout;
+ int request_slowlog_trace_depth;
int request_terminate_timeout;
int rlimit_files;
int rlimit_core;
diff --git a/sapi/fpm/fpm/fpm_php_trace.c b/sapi/fpm/fpm/fpm_php_trace.c
index e6482b6380..2a3a570355 100644
--- a/sapi/fpm/fpm/fpm_php_trace.c
+++ b/sapi/fpm/fpm/fpm_php_trace.c
@@ -42,7 +42,7 @@
static int fpm_php_trace_dump(struct fpm_child_s *child, FILE *slowlog) /* {{{ */
{
- int callers_limit = 20;
+ int callers_limit = child->wp->config->request_slowlog_trace_depth;
pid_t pid = child->pid;
struct timeval tv;
static const int buf_size = 1024;
diff --git a/sapi/fpm/www.conf.in b/sapi/fpm/www.conf.in
index 394e27819d..7a672b71be 100644
--- a/sapi/fpm/www.conf.in
+++ b/sapi/fpm/www.conf.in
@@ -322,6 +322,10 @@ pm.max_spare_servers = 3
; Default Value: 0
;request_slowlog_timeout = 0
+; Depth of slow log stack trace.
+; Default Value: 20
+;request_slowlog_trace_depth = 20
+
; The timeout for serving a single request after which the worker process will
; be killed. This option should be used when the 'max_execution_time' ini option
; does not stop script execution for some reason. A value of '0' means 'off'.