You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Eric Covener <co...@gmail.com> on 2007/12/07 23:55:40 UTC

proxy returning apr_status_t to handler?

It seems like a network I/O error while sending an http proxy request
will result in an apr_status_t being returned all the way up through
the handler.

The other protocol plugins for mod_proxy seem to more safely return
OK/DECLINED or an http status code in these cases.

In 2.2.x and trunk, mod_proxy has a request_status hook which might be
able to take a pass at sanitizing the return code at the last minute,
but this might be overkill compared to just fixing the 'return status'
around the HTTP proxy calls (2.0.x needs to do this anyway)

The particular instance I'm looking at is during the write of the post
body.  In this case I assume HTTP_BAD_GATEWAY should be returned from
proxy_http instead of the status returned from pass_brigade?

-- 
Eric Covener
covener@gmail.com

Re: proxy returning apr_status_t to handler?

Posted by Graham Leggett <mi...@sharp.fm>.
Eric Covener wrote:

> The particular instance I'm looking at is during the write of the post
> body.  In this case I assume HTTP_BAD_GATEWAY should be returned from
> proxy_http instead of the status returned from pass_brigade?

Ideally if sections are found when apr_status_t is sent instead of an 
HTTP code, those sections should be fixed.

Regards,
Graham
--


Re: proxy returning apr_status_t to handler?

Posted by Jeff Trawick <tr...@gmail.com>.
On Dec 7, 2007 5:55 PM, Eric Covener <co...@gmail.com> wrote:

> The particular instance I'm looking at is during the write of the post
> body.  In this case I assume HTTP_BAD_GATEWAY should be returned from
> proxy_http instead of the status returned from pass_brigade?

I'd guess HTTP_GATEWAY_TIME_OUT if we get a timeout error code, and
HTTP_BAD_GATEWAY otherwise...

Re: proxy returning apr_status_t to handler?

Posted by Ruediger Pluem <rp...@apache.org>.

On 12/18/2007 07:50 PM, Jeff Trawick wrote:
> On Dec 18, 2007 12:06 PM, Plüm, Rüdiger, VF-Group
> <ru...@vodafone.com> wrote:
>>
>>> -----Ursprüngliche Nachricht-----
>>> Von: Jeff Trawick
>>> Gesendet: Dienstag, 18. Dezember 2007 17:43
>>> An: dev@httpd.apache.org
>>> Betreff: Re: proxy returning apr_status_t to handler?
>>>
>> Argh. Without further testing: Does the following patch fixes this:
>>
>> Index: modules/proxy/proxy_util.c
>> ===================================================================
>> --- modules/proxy/proxy_util.c  (revision 605247)
>> +++ modules/proxy/proxy_util.c  (working copy)
>> @@ -1601,7 +1601,7 @@
>>  #endif
>>
>>      r = conn->r;
>> -    if (conn->need_flush && r) {
>> +    if (conn->need_flush && r && (r->eos_sent || r->bytes_sent)) {
>>          /*
>>           * We need to ensure that buckets that may have been buffered in the
>>           * network filters get flushed to the network. This is needed since
> 
> Yes; bogus "200 OK" is resolved:

Thanks for testing. Fix committed in r605314.

Regards

Rüdiger


Re: proxy returning apr_status_t to handler?

Posted by Jeff Trawick <tr...@gmail.com>.
On Dec 18, 2007 12:06 PM, Plüm, Rüdiger, VF-Group
<ru...@vodafone.com> wrote:
>
>
> > -----Ursprüngliche Nachricht-----
> > Von: Jeff Trawick
> > Gesendet: Dienstag, 18. Dezember 2007 17:43
> > An: dev@httpd.apache.org
> > Betreff: Re: proxy returning apr_status_t to handler?
>
> >
> >
>
> Argh. Without further testing: Does the following patch fixes this:
>
> Index: modules/proxy/proxy_util.c
> ===================================================================
> --- modules/proxy/proxy_util.c  (revision 605247)
> +++ modules/proxy/proxy_util.c  (working copy)
> @@ -1601,7 +1601,7 @@
>  #endif
>
>      r = conn->r;
> -    if (conn->need_flush && r) {
> +    if (conn->need_flush && r && (r->eos_sent || r->bytes_sent)) {
>          /*
>           * We need to ensure that buckets that may have been buffered in the
>           * network filters get flushed to the network. This is needed since

Yes; bogus "200 OK" is resolved:

HTTP/1.1 500 Internal Server Error
Date: Tue, 18 Dec 2007 18:47:08 GMT
Server: Apache/2.3.0-dev (Unix) DAV/2
Content-Length: 535
Connection: close
Content-Type: text/html; charset=iso-8859-1

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>500 Internal Server Error</title>
</head><body>
<h1>Internal Server Error</h1>
<p>The server encountered an internal error or
misconfiguration and was unable to complete
your request.</p>
<p>Please contact the server administrator,
 you@example.com and inform them of the time the error occurred,
and anything you might have done that may have
caused the error.</p>
<p>More information about this error may be available
in the server error log.</p>
</body></html>
$ tail -1 ~/inst/23/logs/access_log
127.0.0.1 - - [18/Dec/2007:13:47:08 -0500] "POST /readbody.pl HTTP/1.1" 500 535
$ tail -5 ~/inst/23/logs/error_log
[Tue Dec 18 13:47:08 2007] [debug] proxy_util.c(2281): proxy: HTTP:
fam 2 socket created to connect to 127.0.0.1
[Tue Dec 18 13:47:08 2007] [debug] proxy_util.c(2382): proxy: HTTP:
connection complete to 127.0.0.1:8081 (127.0.0.1)
[Tue Dec 18 13:47:13 2007] [error] (70007)The timeout specified has
expired: proxy: prefetch request body failed to 127.0.0.1:8081
(127.0.0.1) from 127.0.0.1 ()
[Tue Dec 18 13:47:13 2007] [debug] proxy_util.c(1995): proxy: HTTP:
has released connection for (127.0.0.1)
[Tue Dec 18 13:47:13 2007] [error] [client 127.0.0.1] Handler for
proxy-server returned invalid result code 70007

Re: proxy returning apr_status_t to handler?

Posted by Plüm, Rüdiger, VF-Group <ru...@vodafone.com>.

> -----Ursprüngliche Nachricht-----
> Von: Jeff Trawick 
> Gesendet: Dienstag, 18. Dezember 2007 17:43
> An: dev@httpd.apache.org
> Betreff: Re: proxy returning apr_status_t to handler?
> 
> 
> On Dec 17, 2007 11:20 AM, Jeff Trawick <tr...@gmail.com> wrote:
> > On Dec 17, 2007 10:27 AM, Nick Kew <ni...@webthing.com> wrote:
> > > On Mon, 17 Dec 2007 10:22:02 -0500
> > > "Eric Covener" <co...@gmail.com> wrote:
> > >
> > > > Thanks; Any particular concerns about the generic fix for 2.0.x?
> > > >
> > > Haven't looked, but if it applies cleanly, then +1 on doing so.
> >
> > same here
> 
> That generic change may just be a temporary diversion when it comes to
> proxy...  Here's an alarming response for a testcase where client
> didn't send enough bytes to satisfy C-L and we timed out:
> 
> HTTP/1.1 200 OK
> Date: Tue, 18 Dec 2007 16:13:36 GMT
> Server: Apache/2.3.0-dev (Unix) DAV/2
> Connection: close
> Transfer-Encoding: chunked
> Content-Type: text/plain
> 
> 1f1
> <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
> <html><head>
> <title>200 OK</title>
> </head><body>
> <h1>OK</h1>
> <p>The server encountered an internal error or
> misconfiguration and was unable to complete
> your request.</p>
> <p>Please contact the server administrator,
> you@example.com and inform them of the time the error occurred,
> and anything you might have done that may have
> caused the error.</p>
> <p>More information about this error may be available
> in the server error log.</p>
> </body></html>
> 
> 127.0.0.1 - - [18/Dec/2007:11:13:36 -0500] "POST /readbody.pl 
> HTTP/1.1" 500 497
> 
> [Tue Dec 18 11:13:41 2007] [error] (70007)The timeout specified has
> expired: proxy: prefetch request body failed to 127.0.0.1:8081
> (127.0.0.1) from 127.0.0.1 ()
> [Tue Dec 18 11:13:41 2007] [debug] proxy_util.c(1995): proxy: HTTP:
> has released connection for (127.0.0.1)
> [Tue Dec 18 11:13:41 2007] [error] [client 127.0.0.1] Handler for
> proxy-server returned invalid result code 70007
> 
> backtrace for where r->status_line gets set to "200 OK":
> 
> Hardware watchpoint 2: r->status_line
> 
> Old value = 0x0
> New value = 0x81493b4 "200 OK"
> basic_http_header_check (r=0x9124228, protocol=0xb74c8d30) at 
> http_filters.c:721
> 721 if (r->proto_num > HTTP_VERSION(1,0)
> (gdb) where
> #0 basic_http_header_check (r=0x9124228, protocol=0xb74c8d30) at
> http_filters.c:721
> #1 0x080e5be5 in ap_http_header_filter (f=0x9125048, b=0x91256f8) at
> http_filters.c:1049
> #2 0x0808c756 in ap_pass_brigade (next=0x9125048, bb=0x91256f8) at
> util_filter.c:527
> #3 0x08071f43 in ap_content_length_filter (f=0x9125030, b=0x91256f8)
> at protocol.c:1337
> #4 0x0808c756 in ap_pass_brigade (next=0x9125030, bb=0x91256f8) at
> util_filter.c:527
> #5 0x080e7374 in ap_byterange_filter (f=0x9125018, bb=0x91256f8) at
> byterange_filter.c:169
> #6 0x0808c756 in ap_pass_brigade (next=0x9125018, bb=0x91256f8) at
> util_filter.c:527
> #7 0x0808c980 in ap_fflush (f=0x9125018, bb=0x91256f8) at 
> util_filter.c:602
> #8 0x080c9e62 in connection_cleanup (theconn=0x9082900) at 
> proxy_util.c:1636
> #9 0x080caad6 in ap_proxy_release_connection (proxy_function=0x8146e2d

Argh. Without further testing: Does the following patch fixes this:

Index: modules/proxy/proxy_util.c
===================================================================
--- modules/proxy/proxy_util.c  (revision 605247)
+++ modules/proxy/proxy_util.c  (working copy)
@@ -1601,7 +1601,7 @@
 #endif
 
     r = conn->r;
-    if (conn->need_flush && r) {
+    if (conn->need_flush && r && (r->eos_sent || r->bytes_sent)) {
         /*
          * We need to ensure that buckets that may have been buffered in the
          * network filters get flushed to the network. This is needed since

BTW: This should only happen with trunk, not with 2.2.x.

Regards

Rüdiger




Re: proxy returning apr_status_t to handler?

Posted by Jeff Trawick <tr...@gmail.com>.
On Dec 17, 2007 11:20 AM, Jeff Trawick <tr...@gmail.com> wrote:
> On Dec 17, 2007 10:27 AM, Nick Kew <ni...@webthing.com> wrote:
> > On Mon, 17 Dec 2007 10:22:02 -0500
> > "Eric Covener" <co...@gmail.com> wrote:
> >
> > > Thanks; Any particular concerns about the generic fix for 2.0.x?
> > >
> > Haven't looked, but if it applies cleanly, then +1 on doing so.
>
> same here

That generic change may just be a temporary diversion when it comes to
proxy...  Here's an alarming response for a testcase where client
didn't send enough bytes to satisfy C-L and we timed out:

HTTP/1.1 200 OK
Date: Tue, 18 Dec 2007 16:13:36 GMT
Server: Apache/2.3.0-dev (Unix) DAV/2
Connection: close
Transfer-Encoding: chunked
Content-Type: text/plain

1f1
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>200 OK</title>
</head><body>
<h1>OK</h1>
<p>The server encountered an internal error or
misconfiguration and was unable to complete
your request.</p>
<p>Please contact the server administrator,
you@example.com and inform them of the time the error occurred,
and anything you might have done that may have
caused the error.</p>
<p>More information about this error may be available
in the server error log.</p>
</body></html>

127.0.0.1 - - [18/Dec/2007:11:13:36 -0500] "POST /readbody.pl HTTP/1.1" 500 497

[Tue Dec 18 11:13:41 2007] [error] (70007)The timeout specified has
expired: proxy: prefetch request body failed to 127.0.0.1:8081
(127.0.0.1) from 127.0.0.1 ()
[Tue Dec 18 11:13:41 2007] [debug] proxy_util.c(1995): proxy: HTTP:
has released connection for (127.0.0.1)
[Tue Dec 18 11:13:41 2007] [error] [client 127.0.0.1] Handler for
proxy-server returned invalid result code 70007

backtrace for where r->status_line gets set to "200 OK":

Hardware watchpoint 2: r->status_line

Old value = 0x0
New value = 0x81493b4 "200 OK"
basic_http_header_check (r=0x9124228, protocol=0xb74c8d30) at http_filters.c:721
721 if (r->proto_num > HTTP_VERSION(1,0)
(gdb) where
#0 basic_http_header_check (r=0x9124228, protocol=0xb74c8d30) at
http_filters.c:721
#1 0x080e5be5 in ap_http_header_filter (f=0x9125048, b=0x91256f8) at
http_filters.c:1049
#2 0x0808c756 in ap_pass_brigade (next=0x9125048, bb=0x91256f8) at
util_filter.c:527
#3 0x08071f43 in ap_content_length_filter (f=0x9125030, b=0x91256f8)
at protocol.c:1337
#4 0x0808c756 in ap_pass_brigade (next=0x9125030, bb=0x91256f8) at
util_filter.c:527
#5 0x080e7374 in ap_byterange_filter (f=0x9125018, bb=0x91256f8) at
byterange_filter.c:169
#6 0x0808c756 in ap_pass_brigade (next=0x9125018, bb=0x91256f8) at
util_filter.c:527
#7 0x0808c980 in ap_fflush (f=0x9125018, bb=0x91256f8) at util_filter.c:602
#8 0x080c9e62 in connection_cleanup (theconn=0x9082900) at proxy_util.c:1636
#9 0x080caad6 in ap_proxy_release_connection (proxy_function=0x8146e2d
"HTTP", conn=0x9082900, s=0x9080910) at proxy_util.c:1998
#10 0x080d5b11 in ap_proxy_http_cleanup (scheme=0x8146e2d "HTTP",
r=0x9124228, backend=0x9082900) at mod_proxy_http.c:1742
#11 0x080d5f9d in proxy_http_handler (r=0x9124228, worker=0x90bf6a8,
conf=0x90bf568, url=0x91209e8 "/cgi-bin/readbody.pl", proxyname=0x0,
proxyport=0)
at mod_proxy_http.c:1872
#12 0x080c67c5 in proxy_run_scheme_handler (r=0x9124228,
worker=0x90bf6a8, conf=0x90bf568, url=0x91253f6
"http://127.0.0.1:8081/cgi-bin/readbody.pl", proxyhost=0x0,
proxyport=0) at mod_proxy.c:2313
#13 0x080c3306 in proxy_handler (r=0x9124228) at mod_proxy.c:945
#14 0x0807fdc3 in ap_run_handler (r=0x9124228) at config.c:163
#15 0x0808050d in ap_invoke_handler (r=0x9124228) at config.c:378
#16 0x080e28f7 in ap_process_async_request (r=0x9124228) at http_request.c:244
#17 0x080e2a18 in ap_process_request (r=0x9124228) at http_request.c:288
#18 0x080df30d in ap_process_http_connection (c=0x91203d0) at http_core.c:208
#19 0x080883e7 in ap_run_process_connection (c=0x91203d0) at connection.c:43
#20 0x080887fb in ap_process_connection (c=0x91203d0, csd=0x9120220)
at connection.c:178
#21 0x0811f6e2 in process_socket (p=0x91201e0, sock=0x9120220,
my_child_num=0, my_thread_num=0, bucket_alloc=0x91221e8) at
worker.c:542
#22 0x08120018 in worker_thread (thd=0x9109328, dummy=0x910b0e0) at worker.c:893

The only thing in the brigade being passed is a flush bucket.

Re: proxy returning apr_status_t to handler?

Posted by Jim Jagielski <ji...@jaguNET.com>.
On Dec 17, 2007, at 11:20 AM, Jeff Trawick wrote:

> On Dec 17, 2007 10:27 AM, Nick Kew <ni...@webthing.com> wrote:
>> On Mon, 17 Dec 2007 10:22:02 -0500
>> "Eric Covener" <co...@gmail.com> wrote:
>>
>>> Thanks; Any particular concerns about the generic fix for 2.0.x?
>>>
>> Haven't looked, but if it applies cleanly, then +1 on doing so.
>
> same here
>
  +1

Re: proxy returning apr_status_t to handler?

Posted by Jeff Trawick <tr...@gmail.com>.
On Dec 17, 2007 10:27 AM, Nick Kew <ni...@webthing.com> wrote:
> On Mon, 17 Dec 2007 10:22:02 -0500
> "Eric Covener" <co...@gmail.com> wrote:
>
> > Thanks; Any particular concerns about the generic fix for 2.0.x?
> >
> Haven't looked, but if it applies cleanly, then +1 on doing so.

same here

Re: proxy returning apr_status_t to handler?

Posted by Nick Kew <ni...@webthing.com>.
On Mon, 17 Dec 2007 10:22:02 -0500
"Eric Covener" <co...@gmail.com> wrote:

> Thanks; Any particular concerns about the generic fix for 2.0.x?
> 
Haven't looked, but if it applies cleanly, then +1 on doing so.

-- 
Nick Kew

Application Development with Apache - the Apache Modules Book
http://www.apachetutor.org/

Re: proxy returning apr_status_t to handler?

Posted by Eric Covener <co...@gmail.com>.
On Dec 10, 2007 4:09 AM, Nick Kew <ni...@webthing.com> wrote:
> On Fri, 7 Dec 2007 17:55:40 -0500
> "Eric Covener" <co...@gmail.com> wrote:
>
> > It seems like a network I/O error while sending an http proxy request
> > will result in an apr_status_t being returned all the way up through
> > the handler.
>
> You might want to read through the evolving story at
> http://issues.apache.org/bugzilla/show_bug.cgi?id=31759
> leading to the generic fix at
> http://svn.apache.org/viewvc?view=rev&revision=448711
>

Thanks; Any particular concerns about the generic fix for 2.0.x?

-- 
Eric Covener
covener@gmail.com

Re: proxy returning apr_status_t to handler?

Posted by Nick Kew <ni...@webthing.com>.
On Fri, 7 Dec 2007 17:55:40 -0500
"Eric Covener" <co...@gmail.com> wrote:

> It seems like a network I/O error while sending an http proxy request
> will result in an apr_status_t being returned all the way up through
> the handler.

You might want to read through the evolving story at
http://issues.apache.org/bugzilla/show_bug.cgi?id=31759
leading to the generic fix at
http://svn.apache.org/viewvc?view=rev&revision=448711

-- 
Nick Kew

Application Development with Apache - the Apache Modules Book
http://www.apachetutor.org/