Joe Schaefer wrote:
Stas Bekman <[EMAIL PROTECTED]> writes:


Joe Schaefer wrote:

Stas Bekman <[EMAIL PROTECTED]> writes:


Now going to try and reduce that sequence to a shorter one...

I don't think you need bother- the brigade loop is miscoded in compat.pm's
content sub- you can't ask for the next bucket *after* $b has been
removed.

why not? it still points to the next bucket, no?


Probably so, because of the way (I think) APR_RING_UNSPLICE is currently implemeted. But IMO that's not guaranteed by the apr_ring.h documentation (unless that's what is meant by "dangling pointers").

And it's not possible to take the pointer to the next bucket before hand, because of the filebucket inplace bucket split, that you've pointed out earlier.


Instead of iterating using for(;;), use while():
 while ($b = $bb->first) {
     ++$seen_eos, last if $b->is_eos;
     if ($b->read(my $buf)) {
         $data .= $buf;
     }
     $b->delete; # APR::Bucket needs to wrap apr_bucket_delete(),
# since APR_BUCKET_REMOVE() doesn't actually
                 # decrement the bucket refcount
                 # so the bucket allocator can reclaim $b
 }

I've been explicitly rewriting the iteration loops recently not to use the
while loop, because for anything more complicated it becomes a mess and too
easy to put $b->delete in the wrong place.


OK, but don't call $b->remove, because its not doing anything
useful.

Well, I use it a lot in filters where I want to reuse the same bucket brigade to only replace those buckets that were modified. I guess it's not needed in this particular case.


Leave the buckets in the brigade and call $bb->cleanup after each inner for() loop, that way the next call to get_brigade
will be able to reuse those buckets (if at all possible).

I wish we could use that. It segfaults: see: modperl-2.0/t/protocol/TestProtocol/echo_bbs2.pm ... # XXX: ideally $bb->cleanup should be used here and no create/destroy # bb every time the loop is entered should be done. But it segfaults # on certain setups: # http://marc.theaimsgroup.com/?l=apache-modperl-dev&m=108967266419527&w=2

I wonder why don't I see the problem right away then, and only after
running a bunch of other tests. Any idea why?


No clue, yet.

:(

--
__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to