Thank you for a reply I will try to answer your questions
> > 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:
>
> Where does that come from, and what breakdown of individual buckets in there?
> Is it by any chance a source (eg pipe or socket) rather than a store?
That is the bucket brigade I got from upper level. I assume, that this is the
file
I am testing the filter on.
I got following for the first bucket in this brigade just when I got it:
APR_BUCKET_IS_METADATA -> 0
APR_BUCKET_IS_FLUSH -> 0
APR_BUCKET_IS_EOS -> 0
APR_BUCKET_IS_FILE -> 1
APR_BUCKET_IS_PIPE -> 0
APR_BUCKET_IS_SOCKET -> 0
APR_BUCKET_IS_HEAP -> 0
APR_BUCKET_IS_TRANSIENT -> 0
APR_BUCKET_IS_IMMORTAL -> 0
APR_BUCKET_IS_MMAP -> 0
APR_BUCKET_IS_POOL -> 0
There are two buckets sized 18567 and 0.
> > 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);
>
> If we hypothesize that your input was a single bucket, then it's
> 3*100 + LAST. And what's wrong is the size of LAST at this point.
> Is LAST by any chance a Heap bucket?
LAST (size 0):
APR_BUCKET_IS_METADATA -> 1
APR_BUCKET_IS_EOS -> 1
LAST->PREV (size 8000)
APR_BUCKET_IS_HEAP -> 1
LAST->PREV->PREV (size 100)
APR_BUCKET_IS_HEAP -> 1
LAST->PREV->PREV->PREV (size 100)
APR_BUCKET_IS_HEAP -> 1
LAST->PREV->PREV->PREV->PREV (size 100)
APR_BUCKET_IS_MMAP -> 1
all other tested flags are 0
> > 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.
>
> And what happens if you traverse it backwards after going forwards?
Then everything is fixed.
In fact everything is OK even if I traverse it forward before doing the
splitting.
Does this mean anything?
Thank you a lot for your reply.
Greetings,
Vlastimil Pavicek, CTU Prague