From 977d79a7242e434da5409f4498ce4a140eea16dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Loyet?= Date: Sat, 29 Jan 2011 11:38:19 +0000 Subject: [PATCH] - Fixed bug #53434 (php-fpm slowlog now also logs the original request). --- NEWS | 1 + sapi/fpm/fpm/fpm_php.c | 6 ++++++ sapi/fpm/fpm/fpm_php.h | 1 + sapi/fpm/fpm/fpm_request.c | 11 +++++++++-- sapi/fpm/fpm/fpm_shm_slots.h | 1 + 5 files changed, 18 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index ac3e8ca7be9..a9d8b9c5bae 100644 --- a/NEWS +++ b/NEWS @@ -110,6 +110,7 @@ . Enforce security in the fastcgi protocol parsing. (ef-lists at email dotde) . Fixed bug #53777 (php-fpm log format now match php_error log format). (fat) + . Fixed bug #53434 (php-fpm slowlog now also logs the original request). (fat) - Readline extension: . Fixed bug #53630 (Fixed parameter handling inside readline() function). diff --git a/sapi/fpm/fpm/fpm_php.c b/sapi/fpm/fpm/fpm_php.c index eeba71301a7..384682b7e22 100644 --- a/sapi/fpm/fpm/fpm_php.c +++ b/sapi/fpm/fpm/fpm_php.c @@ -160,6 +160,12 @@ char *fpm_php_script_filename(TSRMLS_D) /* {{{ */ } /* }}} */ +char *fpm_php_request_uri(TSRMLS_D) /* {{{ */ +{ + return (char *) SG(request_info).request_uri; +} +/* }}} */ + char *fpm_php_request_method(TSRMLS_D) /* {{{ */ { return (char *) SG(request_info).request_method; diff --git a/sapi/fpm/fpm/fpm_php.h b/sapi/fpm/fpm/fpm_php.h index 81e5332671f..891e83bfce9 100644 --- a/sapi/fpm/fpm/fpm_php.h +++ b/sapi/fpm/fpm/fpm_php.h @@ -35,6 +35,7 @@ struct fpm_worker_pool_s; int fpm_php_init_child(struct fpm_worker_pool_s *wp); char *fpm_php_script_filename(TSRMLS_D); +char *fpm_php_request_uri(TSRMLS_D); char *fpm_php_request_method(TSRMLS_D); size_t fpm_php_content_length(TSRMLS_D); void fpm_php_soft_quit(); diff --git a/sapi/fpm/fpm/fpm_request.c b/sapi/fpm/fpm/fpm_request.c index 590548e5763..9a2f66bcecd 100644 --- a/sapi/fpm/fpm/fpm_request.c +++ b/sapi/fpm/fpm/fpm_request.c @@ -26,6 +26,7 @@ void fpm_request_accepting() /* {{{ */ slot = fpm_shm_slots_acquire(0, 0); slot->request_stage = FPM_REQUEST_ACCEPTING; fpm_clock_get(&slot->tv); + memset(slot->request_uri, 0, sizeof(slot->request_uri)); memset(slot->request_method, 0, sizeof(slot->request_method)); slot->content_length = 0; memset(slot->script_filename, 0, sizeof(slot->script_filename)); @@ -51,6 +52,7 @@ void fpm_request_info() /* {{{ */ { TSRMLS_FETCH(); struct fpm_shm_slot_s *slot; + char *request_uri = fpm_php_request_uri(TSRMLS_C); char *request_method = fpm_php_request_method(TSRMLS_C); char *script_filename = fpm_php_script_filename(TSRMLS_C); @@ -58,6 +60,10 @@ void fpm_request_info() /* {{{ */ slot->request_stage = FPM_REQUEST_INFO; fpm_clock_get(&slot->tv); + if (request_uri) { + cpystrn(slot->request_uri, request_uri, sizeof(slot->request_uri)); + } + if (request_method) { cpystrn(slot->request_method, request_method, sizeof(slot->request_method)); } @@ -136,8 +142,9 @@ void fpm_request_check_timed_out(struct fpm_child_s *child, struct timeval *now, fpm_trace_signal(child->pid); - zlog(ZLOG_WARNING, "[pool %s] child %d, script '%s' executing too slow (%d.%06d sec), logging", - child->wp->config->name, (int) child->pid, purified_script_filename, (int) tv.tv_sec, (int) tv.tv_usec); + zlog(ZLOG_WARNING, "[pool %s] child %d, script '%s' (request: \"%s %s\") executing too slow (%d.%06d sec), logging", + child->wp->config->name, (int) child->pid, purified_script_filename, slot_c.request_method, slot_c.request_uri, + (int) tv.tv_sec, (int) tv.tv_usec); } else #endif diff --git a/sapi/fpm/fpm/fpm_shm_slots.h b/sapi/fpm/fpm/fpm_shm_slots.h index 4596c6fada0..d74f1762292 100644 --- a/sapi/fpm/fpm/fpm_shm_slots.h +++ b/sapi/fpm/fpm/fpm_shm_slots.h @@ -19,6 +19,7 @@ struct fpm_shm_slot_s { enum fpm_request_stage_e request_stage; struct timeval accepted; struct timeval tv; + char request_uri[128]; char request_method[16]; size_t content_length; /* used with POST only */ char script_filename[256];