Hiya folks, just wondering what impact (if any) these changes I've been working on would have on mod_perl and filters implemented using mod_perl?
The change is simply that after calling ap_pass_brigade() on a brigade, any subsequent use of that brigade is likely to segfault since the brigade structure really is free'd.
I understood that only the content/buckets are lost, but the bb itself remains re-usable. We have quite a few tests that go like this (.e.g see: t/filter/TestFilter/both_str_con_add.pm):
my $bb = APR::Brigade->new($c->pool, $c->bucket_alloc);
for (;;) { $c->input_filters->get_brigade($bb, Apache::MODE_GETLINE); last if $bb->is_empty;
my $b = APR::Bucket::flush_create($c->bucket_alloc); $bb->insert_tail($b); $c->output_filters->pass_brigade($bb); # fflush is the equivalent of the previous 3 lines of code: # but it's tested elsewhere, here testing flush_create # $c->output_filters->fflush($bb); }
$bb->destroy;
Why should we create bb in a tight loop when we can make things faster and re-use the shell? Sounds like a waste of CPU cycles and memory to me.
I notice the mod_perl pass_brigade documentation includes the necessary "caller relinquishes ownership" caveat:
http://perl.apache.org/docs/2.0/api/Apache/Filter.html#C_pass_brigade_
but the example there processes the brigade both before and after it's passed; is that a doc mistake, or do you really expect to be able to do that in mod_perl?
# ... process $bb
my $rc = $f->next->pass_brigade($bb);
return $rc unless $rc == APR::SUCCESS;
# process $bb
return Apache::OK;
It's a typo, Joe. I've removed that bogus comment. Thanks a lot for the heads up.
Regards,
joe (please CC me on replies)
----- Forwarded message from Joe Orton <[EMAIL PROTECTED]> -----
From: Joe Orton <[EMAIL PROTECTED]> Reply-To: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Mail-Followup-To: [EMAIL PROTECTED] Date: Thu, 17 Jun 2004 10:46:37 +0100 Subject: destroying passed brigades User-Agent: Mutt/1.4.1i
Any further thoughts on this, Cliff or anyone else? At least the core_output_filter, the byterange filter, and the http_header filter will all destroy the brigade which is passed to them. Many other filters presume that it's OK to reuse brigades which have been passed on.
With a combination of filters which assume both ways, it is inevitable that changing apr_brigade_destroy() to actually destroy the brigade structure will break some set of existing filters, unfortunately.
There's also ambiguity about what to do with a passed brigade if the next filter returns an error.
joe
----- End forwarded message -----
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
-- __________________________________________________________________ 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]