You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modules-dev@httpd.apache.org by Jodi Bosa <jo...@gmail.com> on 2012/06/22 17:52:05 UTC

Deleting only bucket in brigade

What do you do in an input filter when you need to remove the only bucket
in the bucket brigade?

The following results in the filter not being called with any of the
subsequent bucket brigades:

    apr_bucket_delete(b);


The following hangs:

    b->length = 0;


In other words, my input filter gets called multiple times (once for each
line (AP_MODE_READLINE)) with a new bucket brigade each time.  For one of
these I want to delete the bucket but it is the only bucket in the brigade.

Re: Deleting only bucket in brigade

Posted by Joe Lewis <jo...@joe-lewis.com>.
On 06/22/2012 12:17 PM, Jodi Bosa wrote:
> excellent - that worked!
>
>      ...
>      tmpBucket = APR_BUCKET_NEXT(b);
>      newBucket = apr_bucket_immortal_create("", (apr_size_t )0, bucketAlloc);
>      APR_BUCKET_INSERT_BEFORE(tmpBucket, newBucket);
>      apr_bucket_delete(b);
>      ...
>
>
> But I'm surprised I haven't seen this in other modules - am I that unique
> in deleting an entire bucket??

You're not the only one who removes buckets.  I delete buckets in one of 
my output filters.  If you need the filters to still be called with an 
empty brigade, the create/insert/delete technique should guarante it's 
not an empty brigade, even though there is no data.

My thoughts are that if a brigade is empty, why pass it on?  You can't 
really parse much data when there is none to be parsed.  Hence, I think 
they get dropped if the brigade is empty by default, but am not 100% 
sure on that.

Joe
--
http://www.silverhawk.net/

Re: Deleting only bucket in brigade

Posted by Jodi Bosa <jo...@gmail.com>.
excellent - that worked!

    ...
    tmpBucket = APR_BUCKET_NEXT(b);
    newBucket = apr_bucket_immortal_create("", (apr_size_t )0, bucketAlloc);
    APR_BUCKET_INSERT_BEFORE(tmpBucket, newBucket);
    apr_bucket_delete(b);
    ...


But I'm surprised I haven't seen this in other modules - am I that unique
in deleting an entire bucket??


On Fri, Jun 22, 2012 at 12:28 PM, Joe Lewis <jo...@joe-lewis.com> wrote:

> On 6/22/12 9:52 AM, Jodi Bosa wrote:
>
>> What do you do in an input filter when you need to remove the only bucket
>> in the bucket brigade?
>>
>> The following results in the filter not being called with any of the
>> subsequent bucket brigades:
>>
>>     apr_bucket_delete(b);
>>
>>
>> The following hangs:
>>
>>     b->length = 0;
>>
>>
>> In other words, my input filter gets called multiple times (once for each
>> line (AP_MODE_READLINE)) with a new bucket brigade each time.  For one of
>> these I want to delete the bucket but it is the only bucket in the
>> brigade.
>>
>>  Can you simply create a new bucket (apr_bucket_alloc_create), insert it
> before the bucket you wish to delete, then delete the old bucket?
>
> Joe
> --
> http://www.silverhawk.net/
>

Re: Deleting only bucket in brigade

Posted by Joe Lewis <jo...@joe-lewis.com>.
On 6/22/12 9:52 AM, Jodi Bosa wrote:
> What do you do in an input filter when you need to remove the only bucket
> in the bucket brigade?
>
> The following results in the filter not being called with any of the
> subsequent bucket brigades:
>
>      apr_bucket_delete(b);
>
>
> The following hangs:
>
>      b->length = 0;
>
>
> In other words, my input filter gets called multiple times (once for each
> line (AP_MODE_READLINE)) with a new bucket brigade each time.  For one of
> these I want to delete the bucket but it is the only bucket in the brigade.
>
Can you simply create a new bucket (apr_bucket_alloc_create), insert it 
before the bucket you wish to delete, then delete the old bucket?

Joe
--
http://www.silverhawk.net/