php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #53434
Patch use_full_request_uri_for_slowlog.diff revision 2013-01-15 07:00 UTC by joey dot cai at gmail dot com

Patch use_full_request_uri_for_slowlog.diff for FPM related Bug #53434

Patch version 2013-01-15 07:00 UTC

Return to Bug #53434 | Download this patch
Patch Revisions:

Developer: joey.cai@gmail.com

commit 54108ba446799a694e480da94d7a11b4cd6d0885
Author: Joe Cai <joey.cai@gmail.com>
Date:   Tue Jan 15 14:00:56 2013

    Slowlog patch

diff --git a/main/SAPI.h b/main/SAPI.h
index 9a063d3..bb56d51 100644
--- a/main/SAPI.h
+++ b/main/SAPI.h
@@ -86,6 +86,7 @@ typedef struct {
 
 	char *path_translated;
 	char *request_uri;
+	char *sapi_request_uri;
 
 	const char *content_type;
 
diff --git a/sapi/fpm/fpm/fpm_main.c b/sapi/fpm/fpm/fpm_main.c
index 3faf308..9f3206c 100644
--- a/sapi/fpm/fpm/fpm_main.c
+++ b/sapi/fpm/fpm/fpm_main.c
@@ -1071,6 +1071,7 @@ static void init_request_info(TSRMLS_D)
 	SG(request_info).proto_num = 1000;
 	SG(request_info).query_string = NULL;
 	SG(request_info).request_uri = NULL;
+	SG(request_info).sapi_request_uri = NULL;
 	SG(request_info).content_type = NULL;
 	SG(request_info).content_length = 0;
 	SG(sapi_headers).http_response_code = 200;
@@ -1366,6 +1367,25 @@ static void init_request_info(TSRMLS_D)
 		}
 
 		SG(request_info).request_method = sapi_cgibin_getenv("REQUEST_METHOD", sizeof("REQUEST_METHOD") - 1 TSRMLS_CC);
+		char *http_host = sapi_cgibin_getenv("HTTP_HOST", sizeof("HTTP_HOST") - 1 TSRMLS_CC);
+		char *request_uri = sapi_cgibin_getenv("REQUEST_URI", sizeof("REQUEST_URI") - 1 TSRMLS_CC);
+		unsigned int http_host_len = http_host ? strlen(http_host) : 0;
+		unsigned int request_uri_len = request_uri ? strlen(request_uri) : 0;
+		unsigned int sapi_request_uri_len = http_host_len + request_uri_len;
+
+		char *sapi_request_uri = NULL;
+		sapi_request_uri = emalloc(sapi_request_uri_len + 1);
+
+		/** Concat http_host and request_uri into sapi_request_uri **/
+		if (http_host) {
+			memcpy(sapi_request_uri, http_host, http_host_len + 1);
+		}
+		if (request_uri) {
+			memcpy(sapi_request_uri + http_host_len, request_uri, request_uri_len + 1);
+		}
+
+		SG(request_info).sapi_request_uri = sapi_request_uri;
+
 		/* FIXME - Work out proto_num here */
 		SG(request_info).query_string = sapi_cgibin_getenv("QUERY_STRING", sizeof("QUERY_STRING") - 1 TSRMLS_CC);
 		SG(request_info).content_type = (content_type ? content_type : "" );
diff --git a/sapi/fpm/fpm/fpm_php.c b/sapi/fpm/fpm/fpm_php.c
index cd4d3ae..01b2396 100644
--- a/sapi/fpm/fpm/fpm_php.c
+++ b/sapi/fpm/fpm/fpm_php.c
@@ -165,7 +165,7 @@ char *fpm_php_script_filename(TSRMLS_D) /* {{{ */
 
 char *fpm_php_request_uri(TSRMLS_D) /* {{{ */
 {
-	return (char *) SG(request_info).request_uri;
+	return (char *) SG(request_info).sapi_request_uri;
 }
 /* }}} */
 
diff --git a/sapi/fpm/fpm/fpm_request.c b/sapi/fpm/fpm/fpm_request.c
index 28332d0..ac999a6 100644
--- a/sapi/fpm/fpm/fpm_request.c
+++ b/sapi/fpm/fpm/fpm_request.c
@@ -266,7 +266,7 @@ 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' (request: \"%s %s\") executing too slow (%d.%06d sec), logging",
+			zlog(ZLOG_WARNING, "[pool %s] child %d, script '%s' (request: \"%s http://%s\") executing too slow (%d.%06d sec), logging",
 				child->wp->config->name, (int) child->pid, purified_script_filename, proc.request_method, proc.request_uri,
 				(int) tv.tv_sec, (int) tv.tv_usec);
 		}
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Mon Apr 21 00:02:04 2014 UTC