From: Jim Jagielski
Date: Mon, 12 Jan 2009 13:59:56 +0000 (+0000)
Subject: Merge r729586, r732504 from trunk:
X-Git-Tag: 2.2.12~264
X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d066ba3e9291dd6922df03ab5e90ee17c94fac30;p=thirdparty%2Fapache%2Fhttpd.git
Merge r729586, r732504 from trunk:
CGI: return 504 (Gateway timeout) rather than 500 when a script
times out before returning status line/headers.
PR 42190
Improve canned 504 error message in the light of r729586 and covener's comment.
Submitted by: niq
Reviewed/backported by: jim
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.2.x@733757 13f79535-47bb-0310-9956-ffa450edef68
---
diff --git a/CHANGES b/CHANGES
index 5d9f559041d..199f3e72b8f 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,10 @@
-*- coding: utf-8 -*-
Changes with Apache 2.2.12
+ *) CGI: return 504 (Gateway timeout) rather than 500 when a script
+ times out before returning status line/headers.
+ PR 42190 [Nick Kew]
+
*) prefork: Log an error instead of segfaulting when child startup fails
due to pollset creation failures. PR 46467. [Jeff Trawick]
diff --git a/STATUS b/STATUS
index 6b4ba0e10e0..302bf1b9d38 100644
--- a/STATUS
+++ b/STATUS
@@ -114,13 +114,6 @@ PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
trunk works
+1 covener, niq, rpluem
- * util_script (CGI): return 504 (Gateway timeout) rather than 500
- when a script times out before returning status line/headers.
- PR 42190
- http://svn.apache.org/viewvc?view=rev&revision=729586
- http://svn.apache.org/viewvc?view=rev&revision=732504
- +1: niq, rpluem, jim
-
PATCHES PROPOSED TO BACKPORT FROM TRUNK:
[ New proposals should be added at the end of the list ]
diff --git a/modules/http/http_protocol.c b/modules/http/http_protocol.c
index 10e6514b617..046e98bc579 100644
--- a/modules/http/http_protocol.c
+++ b/modules/http/http_protocol.c
@@ -1044,8 +1044,8 @@ static const char *get_canned_error_string(int status,
"request due to maintenance downtime or capacity\n"
"problems. Please try again later.
\n");
case HTTP_GATEWAY_TIME_OUT:
- return("The proxy server did not receive a timely response\n"
- "from the upstream server.
\n");
+ return("The gateway did not receive a timely response\n"
+ "from the upstream server or application.
\n");
case HTTP_NOT_EXTENDED:
return("A mandatory extension policy in the request is not\n"
"accepted by the server for this resource.
\n");
diff --git a/server/util_script.c b/server/util_script.c
index 09c8dd414d7..6d6f3f4a630 100644
--- a/server/util_script.c
+++ b/server/util_script.c
@@ -430,12 +430,19 @@ AP_DECLARE(int) ap_scan_script_header_err_core(request_rec *r, char *buffer,
while (1) {
- if ((*getsfunc) (w, MAX_STRING_LEN - 1, getsfunc_data) == 0) {
+ int rv = (*getsfunc) (w, MAX_STRING_LEN - 1, getsfunc_data);
+ if (rv == 0) {
ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_TOCLIENT, 0, r,
"Premature end of script headers: %s",
apr_filepath_name_get(r->filename));
return HTTP_INTERNAL_SERVER_ERROR;
}
+ else if (rv == -1) {
+ ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_TOCLIENT, 0, r,
+ "Script timed out before returning headers: %s",
+ apr_filepath_name_get(r->filename));
+ return HTTP_GATEWAY_TIME_OUT;
+ }
/* Delete terminal (CR?)LF */
@@ -629,7 +636,7 @@ static int getsfunc_BRIGADE(char *buf, int len, void *arg)
rv = apr_bucket_read(e, &bucket_data, &bucket_data_len,
APR_BLOCK_READ);
if (rv != APR_SUCCESS || (bucket_data_len == 0)) {
- return 0;
+ return APR_STATUS_IS_TIMEUP(rv) ? -1 : 0;
}
src = bucket_data;
src_end = bucket_data + bucket_data_len;