You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Brandon Fosdick <bf...@bfoz.net> on 2006/04/22 06:54:26 UTC
Buckets and brigades
Can I impose upon somebody to explain buckets and brigades to me? That is, assuming you guys are finished arguing about copyrights. :)
Specifically, I'd like to know how they relate to request processing, but also how they work in general. I know that a brigade is a FIFO of buckets, but...
I'm looking at mod_dav and there's a spot in the PUT handler where it creates a brigade, and then gets a brigade, using the same pointer, like so...
apr_bucket_brigade *bb;
bb = apr_brigade_create(r->pool, r->connection->bucket_alloc);
rc = ap_get_brigade(r->input_filters, bb, AP_MODE_READBYTES,
APR_BLOCK_READ, DAV_READ_BLOCKSIZE);
Does the call to ap_get_brigade() trash the brigade created by apr_brigade_create()?
What exactly is ap_get_brigade() getting? input filters? it looks like it should be getting the request body, not a filter.
thanks
Re: Buckets and brigades
Posted by Tom Hoefakker <tw...@iw.net>.
you "pull" (ap_get_brigade) from the input filters and "push"
(ap_pass_brigade) to the output filters.
So yes, at first the "next" in the context of input filters may seem a
little backwards as you start with the last filter and pull from what
you may visualize as the "previous" filter.
Tom
Brandon Fosdick wrote:
> Nick Kew wrote:
>> http://www.apachetutor.org/dev/brigades
>
> Thanks. What book are you referring to?
>
>>> apr_bucket_brigade *bb;
>>> bb = apr_brigade_create(r->pool, r->connection->bucket_alloc);
>>> rc = ap_get_brigade(r->input_filters, bb, AP_MODE_READBYTES,
>>> APR_BLOCK_READ, DAV_READ_BLOCKSIZE);
>>
>> That's standard for the input chain. ap_get_brigade just populates
>> the brigade that was just created.
>
> ah, it creates an empty brigade and then fills it with the request
> body...that makes more sense.
> By "populate", do you mean that it's making a copy of the bits?
>
> I found ap_get_brigade in util_filter.h, and it says that it gets "the
> current bucket brigade from the next filter on the filter stack".
> Intuitively (for me), "next filter" refers to a filter that has yet to
> be called, so how does it already have the brigade when the "current
> filter" doesn't? And then, right below that, is ap_pass_brigade, which
> passes the brigade to the "next filter". I don't see anything about
> previous filters. Am I looking at typos or am I missing something?
>
Re: Buckets and brigades
Posted by Brandon Fosdick <bf...@bfoz.net>.
Nick Kew wrote:
> http://www.apachetutor.org/dev/brigades
Thanks. What book are you referring to?
>> apr_bucket_brigade *bb;
>> bb = apr_brigade_create(r->pool, r->connection->bucket_alloc);
>> rc = ap_get_brigade(r->input_filters, bb, AP_MODE_READBYTES,
>> APR_BLOCK_READ, DAV_READ_BLOCKSIZE);
>
> That's standard for the input chain. ap_get_brigade just populates
> the brigade that was just created.
ah, it creates an empty brigade and then fills it with the request body...that makes more sense.
By "populate", do you mean that it's making a copy of the bits?
I found ap_get_brigade in util_filter.h, and it says that it gets "the current bucket brigade from the next filter on the filter stack". Intuitively (for me), "next filter" refers to a filter that has yet to be called, so how does it already have the brigade when the "current filter" doesn't? And then, right below that, is ap_pass_brigade, which passes the brigade to the "next filter". I don't see anything about previous filters. Am I looking at typos or am I missing something?
Re: Buckets and brigades
Posted by Nick Kew <ni...@webthing.com>.
On Saturday 22 April 2006 05:54, Brandon Fosdick wrote:
> Can I impose upon somebody to explain buckets and brigades to me?
http://www.apachetutor.org/dev/brigades
(though writing the book brings it home just how hopelessly inadequate
that little tutorial is :-( )
> That is,
> assuming you guys are finished arguing about copyrights. :)
That one's copyright is simple enough:-)
> Specifically, I'd like to know how they relate to request processing, but
> also how they work in general. I know that a brigade is a FIFO of buckets,
An APR_RING, or doubly linked list.
> I'm looking at mod_dav and there's a spot in the PUT handler where it
> creates a brigade, and then gets a brigade, using the same pointer, like
> so...
>
> apr_bucket_brigade *bb;
> bb = apr_brigade_create(r->pool, r->connection->bucket_alloc);
> rc = ap_get_brigade(r->input_filters, bb, AP_MODE_READBYTES,
> APR_BLOCK_READ, DAV_READ_BLOCKSIZE);
That's standard for the input chain. ap_get_brigade just populates
the brigade that was just created.
--
Nick Kew
Re: Buckets and brigades
Posted by Ruediger Pluem <rp...@apache.org>.
On 04/22/2006 06:54 AM, Brandon Fosdick wrote:
> Can I impose upon somebody to explain buckets and brigades to me? That
http://www.apachetutor.org/dev/brigades
Should be a good start for you.
Regards
RĂ¼diger