Stas Bekman <[EMAIL PROTECTED]> writes: [...]
> Joe, there is a test where setaside is needed for real. It's: > > t/filter/TestFilter/in_bbs_inject_header.pm: # it can be stashed > away (missing $b->setaside wrapper): > > # XXX: this is broken: the bucket must be set-aside before > # it can be stashed away (missing $b->setaside wrapper) > push @{ $ctx->{buckets} }, $b; > debug "queued header [$data]"; > inject_header_bucket($bb, $ctx); > next; # inject_header_bucket already called insert_tail > # notice that if we didn't inject any headers, this will > # still work ok, as inject_header_bucket will send the > # separator header which we just pushed to its queue > > If you can deploy it there, that would be great. No problem. Is this what you have in mind? Index: t/filter/TestFilter/in_bbs_inject_header.pm =================================================================== RCS file: /home/cvs/modperl-2.0/t/filter/TestFilter/in_bbs_inject_header.pm,v retrieving revision 1.12 diff -u -r1.12 in_bbs_inject_header.pm --- t/filter/TestFilter/in_bbs_inject_header.pm 4 Oct 2004 02:16:42 -0000 1.12 +++ t/filter/TestFilter/in_bbs_inject_header.pm 4 Oct 2004 03:30:12 -0000 @@ -179,7 +179,9 @@ if ($data and $data =~ /^POST/) { # demonstrate how to add a header while processing other headers my $header = "$header1_key: $header1_val\n"; - push @{ $ctx->{buckets} }, APR::Bucket->new($c->bucket_alloc, $header); + my $bucket = APR::Bucket->new($c->bucket_alloc, $header); + $bucket->setaside($c->pool); + push @{ $ctx->{buckets} }, $bucket; debug "queued header [$header]"; } elsif ($data =~ /^[\r\n]+$/) { @@ -197,7 +199,9 @@ # time to add extra headers: for my $key (keys %headers) { my $header = "$key: $headers{$key}\n"; - push @{ $ctx->{buckets} }, APR::Bucket->new($c->bucket_alloc, $header); + my $bucket = APR::Bucket->new($c->bucket_alloc, $header); + $bucket->setaside($c->pool); + push @{ $ctx->{buckets} }, $bucket; debug "queued header [$header]"; } @@ -205,8 +209,8 @@ # the separator header will be sent as a last header # so we send one newly added header and push the separator # to the end of the queue - # XXX: this is broken: the bucket must be set-aside before - # it can be stashed away (missing $b->setaside wrapper) + + $b->setaside($c->pool); push @{ $ctx->{buckets} }, $b; debug "queued header [$data]"; inject_header_bucket($bb, $ctx); One criticism I have about this test- it is technically incorrect to store the setaside buckets in a Perl array instead of keeping them in a bucket brigade. That's because any buckets left-over in the array will not get destroyed, which can cause a memory leak. It is always good practice to always keep buckets in brigades, because the brigade's cleanup should take care of this (which is the reason why calling destroy() on a brigade is inferior to calling cleanup()). -- Joe Schaefer --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]