Hello,

at first sorry for a quite longer mail(and for a bad english).

I am a student working on a project including an apache output filter. I 
encountered a strange behavior of a bucket brigade
when it is traversed from the last bucket (APR_BRIGADE_LAST(..)) to the first 
one (APR_BRIGADE_FIRST(..)) using
APR_BUCKET_PREV(..).

For testing purposes I splitted incoming bucket brigade (size 18567) using:

b=APR_BRIGADE_FIRST(bb);
if(apr_bucket_split(b,100)!=APR_SUCCESS) my_error(1);
        
b=APR_BUCKET_NEXT(b);
if(apr_bucket_split(b,100)!=APR_SUCCESS) my_error(2);
                
b=APR_BUCKET_NEXT(b);
if(apr_bucket_split(b,100)!=APR_SUCCESS) my_error(3);

Then I try to traverse the brigade from the last bucket to the first one:

b=APR_BRIGADE_LAST(bb);
while(b!=APR_BRIGADE_SENTINEL(bb)) {

    ..dump the contents of bucket into file to see it's contents

    b=APR_BUCKET_PREV(b);
}

I got a set of files with the contents of individual buckets.

Then I traverse the brigade from the first bucket to the last one:

b=APR_BRIGADE_FIRST(bb);
while(b!=APR_BRIGADE_SENTINEL(bb)) {

    ..dump the contents of bucket into file to see it's contents

    b=APR_BUCKET_NEXT(b);
}

I got an another set files with the contents of individual buckets.

The problem is, that the bucket contents set I get when traversing from the 
last to the first is not complete.
This way I get five files sized 0, 8000, 100, 100 and 100 -> that is 8300 total 
instead of 16888

While traversing from the first to the last I got 7 files sized 100, 100, 100, 
8000, 8000 and 2267
-> that is correctly 18567.

I wonder, why there is a difference. The contents of corresponding files are 
right. After a brief look
into the apache sources (apr_bucket_shared_split, apr_bucket_simple_split, 
APR_BUCKET_INSERT_AFTER,
APR_RING_INSERT_AFTER, APR_RING_SPLICE_AFTER) everything seems OK to me 
(connecting buckets).

Please does anyone have an idea why this is not working? Is the way I split the 
buckets correct?
I am not sure if it is a bug in apache or in my code. I use apache 2.0.55 from 
debian testing.

I look forward to any reply, greetings

Vlastimil Pavicek, CTU Prague

Reply via email to