You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Justin Erenkrantz <je...@apache.org> on 2002/06/01 01:40:10 UTC

Discarding bodies multiple times

On Fri, May 31, 2002 at 02:21:52PM -0700, Ryan Bloom wrote:
> Without this fix, the entire test suite fails, because the HTTP_IN
> filter is sending requests with 0 Content-Length to the
> CORE_INPUT_FILTER to read the body.  This means that every request times
> out after some timeout.  It has nothing to do with Jeff's problem,
> because EVERY test was taking forever.  I did run the test-suite, so if
> this breaks anything, there is no test for it.

Well, it's any request where ap_discard_request_body() is called
more than once.  In the case of apache/404.t, default_handler calls
ap_discard_request_body() and then ap_die() calls it too.

I'm not terribly sure if this sequence is valid.  Why is
default_handler discarding the body if it can't handle the
request?  Shouldn't we only discard the body right before we
send the response?  

Or, we could add an eos_gotten to request_rec to indiciate
that the input filters have received EOS so that
discard_request_body won't be re-entrant.  I dunno.  -- justin

Re: Discarding bodies multiple times

Posted by Justin Erenkrantz <je...@apache.org>.
On Sat, Jun 01, 2002 at 01:14:39PM -0400, Cliff Woolley wrote:
> On Fri, 31 May 2002, Ryan Bloom wrote:
> 
> > A filter should NEVER call ap_die.  At the very worst, it should create
> > an error bucket and send it down the stack.
> 
> What about ap_http_header_filter() at line 1460 of http_protocol.c?
>
<snip>
> 
> Is that an exception to that rule?

IMHO, yes.  ap_http_header_filter() is the guy who eats the error
buckets and figures out what to do with it - in this case - call
ap_die().  -- justin

RE: Discarding bodies multiple times

Posted by Cliff Woolley <jw...@virginia.edu>.
On Sat, 1 Jun 2002, Ryan Bloom wrote:

> Not so much an exception as proof.  :-)  That is the code that is
> executed when a filter sends an error_bucket down the stack.  :-)

Uggh.  I KNOW that.  :)  My point is that it *is* possible for a filter to
call ap_die(), meaning it IS possible for ap_discard_request_body() to get
called twice in one request.  I'm asking if that's accounted for.  I think
this case came up within the last week, so it probably is accounted for,
I'm just asking.

--Cliff


RE: Discarding bodies multiple times

Posted by Ryan Bloom <rb...@covalent.net>.
> From: Cliff Woolley [mailto:jwoolley@virginia.edu]
> 
> On Fri, 31 May 2002, Ryan Bloom wrote:
> 
> > A filter should NEVER call ap_die.  At the very worst, it should
create
> > an error bucket and send it down the stack.
> 
> What about ap_http_header_filter() at line 1460 of http_protocol.c?
> 
>     APR_BRIGADE_FOREACH(e, b) {
>         if (e->type == &ap_bucket_type_error) {
>             ap_bucket_error *eb = e->data;
> 
>             ap_die(eb->status, r);
>             return AP_FILTER_ERROR;
>         }
>     }
> 
> Is that an exception to that rule?  (I did a grep for ap_die and this
was
> the only case of it being used in a filter... but I knew about this
one
> when I sent my original message because I ran into this one just the
other
> day.)

Not so much an exception as proof.  :-)  That is the code that is
executed when a filter sends an error_bucket down the stack.  :-)

Ryan



RE: Discarding bodies multiple times

Posted by Cliff Woolley <jw...@virginia.edu>.
On Fri, 31 May 2002, Ryan Bloom wrote:

> A filter should NEVER call ap_die.  At the very worst, it should create
> an error bucket and send it down the stack.

What about ap_http_header_filter() at line 1460 of http_protocol.c?

    APR_BRIGADE_FOREACH(e, b) {
        if (e->type == &ap_bucket_type_error) {
            ap_bucket_error *eb = e->data;

            ap_die(eb->status, r);
            return AP_FILTER_ERROR;
        }
    }

Is that an exception to that rule?  (I did a grep for ap_die and this was
the only case of it being used in a filter... but I knew about this one
when I sent my original message because I ran into this one just the other
day.)

--Cliff


RE: Discarding bodies multiple times

Posted by Ryan Bloom <rb...@covalent.net>.
> From: Cliff Woolley [mailto:jwoolley@virginia.edu]
> 
> On Fri, 31 May 2002, Ryan Bloom wrote:
> 
> > The default handler discards the body, because it can't handle a
body.
> > The assumption is that if the request gets to default_handler, then
no
> > body will be allowed.  There are only two options as I see it.  1)
Keep
> > a record of having received an EOS in the request_rec.  2)  Only
call
> > ap_discard_request_body if the default_handler will succeed.
> 
> You two are agreeing.. it's scaring me.  ;)
> 
> As for option #2... it seems cleaner, but can't a filter call
ap_die()?
> What then?

A filter should NEVER call ap_die.  At the very worst, it should create
an error bucket and send it down the stack.

Ryan




RE: Discarding bodies multiple times

Posted by Cliff Woolley <jw...@virginia.edu>.
On Fri, 31 May 2002, Ryan Bloom wrote:

> The default handler discards the body, because it can't handle a body.
> The assumption is that if the request gets to default_handler, then no
> body will be allowed.  There are only two options as I see it.  1)  Keep
> a record of having received an EOS in the request_rec.  2)  Only call
> ap_discard_request_body if the default_handler will succeed.

You two are agreeing.. it's scaring me.  ;)

As for option #2... it seems cleaner, but can't a filter call ap_die()?
What then?

--Cliff


RE: Discarding bodies multiple times

Posted by Ryan Bloom <rb...@covalent.net>.
> From: Justin Erenkrantz [mailto:jerenkrantz@apache.org]
> 
> On Fri, May 31, 2002 at 02:21:52PM -0700, Ryan Bloom wrote:
> > Without this fix, the entire test suite fails, because the HTTP_IN
> > filter is sending requests with 0 Content-Length to the
> > CORE_INPUT_FILTER to read the body.  This means that every request
times
> > out after some timeout.  It has nothing to do with Jeff's problem,
> > because EVERY test was taking forever.  I did run the test-suite, so
if
> > this breaks anything, there is no test for it.
> 
> Well, it's any request where ap_discard_request_body() is called
> more than once.  In the case of apache/404.t, default_handler calls
> ap_discard_request_body() and then ap_die() calls it too.
> 
> I'm not terribly sure if this sequence is valid.  Why is
> default_handler discarding the body if it can't handle the
> request?  Shouldn't we only discard the body right before we
> send the response?

The default handler discards the body, because it can't handle a body.
The assumption is that if the request gets to default_handler, then no
body will be allowed.  There are only two options as I see it.  1)  Keep
a record of having received an EOS in the request_rec.  2)  Only call
ap_discard_request_body if the default_handler will succeed.

Ryan
> 
> Or, we could add an eos_gotten to request_rec to indiciate
> that the input filters have received EOS so that
> discard_request_body won't be re-entrant.  I dunno.  -- justin