]> granicus.if.org Git - apache/commitdiff
CGI: return 504 (Gateway timeout) rather than 500 when a script
authorNick Kew <niq@apache.org>
Sat, 27 Dec 2008 03:53:32 +0000 (03:53 +0000)
committerNick Kew <niq@apache.org>
Sat, 27 Dec 2008 03:53:32 +0000 (03:53 +0000)
times out before returning status line/headers.
PR 42190

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@729586 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
server/util_script.c

diff --git a/CHANGES b/CHANGES
index 683bbbb481a0b4e3fe8e367a4d80d63642ea13c7..580a2ead29a2b9fa9ca353db44600d8a94c9253c 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,10 @@
 Changes with Apache 2.3.1
 [ When backported to 2.2.x, remove entry from this file ]
 
+ *) CGI: return 504 (Gateway timeout) rather than 500 when a script
+    times out before returning status line/headers.
+    PR 42190 [Nick Kew]
+
  *) mod_cgid: fix segfault problem on solaris.
     PR 39332 [Masaoki Kobayashi <masaoki techfirm.co.jp>]
 
index 4dd8afdd36dfad3c804ab88151d86ae5c4b903d9..11c10fd87c848e4512c2fcf430ba4b0f0d177592 100644 (file)
@@ -429,12 +429,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 */
 
@@ -631,7 +638,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;