You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by ni...@apache.org on 2008/12/27 04:53:32 UTC

svn commit: r729586 - in /httpd/httpd/trunk: CHANGES server/util_script.c

Author: niq
Date: Fri Dec 26 19:53:32 2008
New Revision: 729586

URL: http://svn.apache.org/viewvc?rev=729586&view=rev
Log:
CGI: return 504 (Gateway timeout) rather than 500 when a script
times out before returning status line/headers.
PR 42190

Modified:
    httpd/httpd/trunk/CHANGES
    httpd/httpd/trunk/server/util_script.c

Modified: httpd/httpd/trunk/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=729586&r1=729585&r2=729586&view=diff
==============================================================================
--- httpd/httpd/trunk/CHANGES [utf-8] (original)
+++ httpd/httpd/trunk/CHANGES [utf-8] Fri Dec 26 19:53:32 2008
@@ -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>]
 

Modified: httpd/httpd/trunk/server/util_script.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/util_script.c?rev=729586&r1=729585&r2=729586&view=diff
==============================================================================
--- httpd/httpd/trunk/server/util_script.c (original)
+++ httpd/httpd/trunk/server/util_script.c Fri Dec 26 19:53:32 2008
@@ -429,12 +429,19 @@
 
     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 @@
         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;



Re: svn commit: r729586 - in /httpd/httpd/trunk: CHANGES server/util_script.c

Posted by André Malo <nd...@perlig.de>.
* Nick Kew wrote: 


> On 8 Jan 2009, at 10:34, Joe Orton wrote:
> > I don't see why 504 is more appropriate than 500 for this case.
> >
> > 504 is specifically defined for cases where the server is acting as a
> > gateway or proxy, which it is not here.  (by the 2616 definitions of
> > gateway and proxy)
> >
> > joe
>
> One might consider the G of CGI a clue.
>
> The fact that the backend is (usually) an application running locally
> on the
> same machine as the webserver doesn't preclude the latter being a
> gateway.
>
> Come to think of it, CGI errors fall into more categories than we allow.
> A misconfiguration is indeed Internal Server Error.  But a script
> that generates
> garbage is an External Server Error, and a 502 response would be in
> order.
> It would be no bad thing to point the finger of blame at broken scripts
> rather than confuse the authors with "internal" errors.

Generally spoken, the message ist mostly not seen by authors, but by users. 
For *them* it's an opaque error (and should be), no matter what.

nd

Re: svn commit: r729586 - in /httpd/httpd/trunk: CHANGES server/util_script.c

Posted by Nick Kew <ni...@webthing.com>.
On 8 Jan 2009, at 10:34, Joe Orton wrote:

>
> I don't see why 504 is more appropriate than 500 for this case.
>
> 504 is specifically defined for cases where the server is acting as a
> gateway or proxy, which it is not here.  (by the 2616 definitions of
> gateway and proxy)
>
> joe

One might consider the G of CGI a clue.

The fact that the backend is (usually) an application running locally  
on the
same machine as the webserver doesn't preclude the latter being a  
gateway.

Come to think of it, CGI errors fall into more categories than we allow.
A misconfiguration is indeed Internal Server Error.  But a script  
that generates
garbage is an External Server Error, and a 502 response would be in  
order.
It would be no bad thing to point the finger of blame at broken scripts
rather than confuse the authors with "internal" errors.

-- 
Nick Kew

Re: svn commit: r729586 - in /httpd/httpd/trunk: CHANGES server/util_script.c

Posted by Joe Orton <jo...@redhat.com>.
On Wed, Jan 07, 2009 at 02:34:29PM -0500, Eric Covener wrote:
> On Fri, Dec 26, 2008 at 10:53 PM,  <ni...@apache.org> wrote:
> > Author: niq
> > Date: Fri Dec 26 19:53:32 2008
> > New Revision: 729586
> >
> > URL: http://svn.apache.org/viewvc?rev=729586&view=rev
> > Log:
> > CGI: return 504 (Gateway timeout) rather than 500 when a script
> > times out before returning status line/headers.
> > PR 42190
> 
> Any concern that canned message for 504 is going to cause confusion?

I don't see why 504 is more appropriate than 500 for this case.

504 is specifically defined for cases where the server is acting as a 
gateway or proxy, which it is not here.  (by the 2616 definitions of 
gateway and proxy)

joe

Re: svn commit: r729586 - in /httpd/httpd/trunk: CHANGES server/util_script.c

Posted by Nick Kew <ni...@webthing.com>.
On 7 Jan 2009, at 19:34, Eric Covener wrote:

> On Fri, Dec 26, 2008 at 10:53 PM,  <ni...@apache.org> wrote:
>> Author: niq
>> Date: Fri Dec 26 19:53:32 2008
>> New Revision: 729586
>>
>> URL: http://svn.apache.org/viewvc?rev=729586&view=rev
>> Log:
>> CGI: return 504 (Gateway timeout) rather than 500 when a script
>> times out before returning status line/headers.
>> PR 42190
>
> Any concern that canned message for 504 is going to cause confusion?
>
>>> The proxy server did not receive a timely response from the  
>>> upstream server.

It's a fair cop, guv.  Substituting

   "The gateway did not receive a timely response
   from the upstream server or application."

r732504

-- 
Nick Kew

Re: svn commit: r729586 - in /httpd/httpd/trunk: CHANGES server/util_script.c

Posted by Eric Covener <co...@gmail.com>.
On Fri, Dec 26, 2008 at 10:53 PM,  <ni...@apache.org> wrote:
> Author: niq
> Date: Fri Dec 26 19:53:32 2008
> New Revision: 729586
>
> URL: http://svn.apache.org/viewvc?rev=729586&view=rev
> Log:
> CGI: return 504 (Gateway timeout) rather than 500 when a script
> times out before returning status line/headers.
> PR 42190

Any concern that canned message for 504 is going to cause confusion?

>> The proxy server did not receive a timely response from the upstream server.

-- 
Eric Covener
covener@gmail.com