Re: $bb,$b, PerlOutputFilterHandler and $rv = $f->pass_brigade($bb);
[prev]
[thread]
[next]
[Date index for 2004/12/19]
"eps com estem" <ggerard@xxxxxxx.xxx> writes:
[...]
> 1)- First thing is that if i am creating a new bucket for a new
> brigade, the line
> my $b = APR::Bucket->new($bb->bucket_alloc,$data);
> should be
> my $b = APR::Bucket->new($bb_ctx->bucket_alloc,$data);
> or that's what i think(?).
Makes no difference; they all should reference the
same internal allocator (f->c->bucket_alloc).
> With this change in the first codes the situation however doesn't
> change.
>
> 2)- Second thing is that, in a try to "finish" the transaction i
> wanted to create an eos stream. Docs say
> use APR::Bucket ();
> use Apache::Connection ();
> my $ba = $c->bucket_alloc;
> my $eos_b = APR::Bucket::eos_create($ba);
Syntactically correct, but normally you shouldn't create
your own eos bucket. The upstream filter will eventually
send one to your filter, so its better to just pass *that*
one along when it comes.
> so
> my $eos_b = APR::Bucket->eos_create($f->c->bucket_alloc);
> should work ... or not ...
No that doesn't work. The error message is correct,
eos_create only takes one argument: an APR::BucketAlloc
object.
> If i put
> my $eos_b = APR::Bucket::eos_create($f->c->bucket_alloc);
> there's no more Internal Error, but page appears (after 8-10 seconds)
> truncated.
Right. Your filter may be invoked multiple times
for a single request. By inserting the eos
bucket too soon, you wind up confusing both apache
and the browser. The eos bucket tells downstream
filters that no more content will be coming, so
apache won't send any more data even if the browser
is expecting it.
> a) :: is not equal to ->? i though yes but i have not verified
They're different. The -> is a (class) method call,
so perl will do an OO lookup for the proper method
and adjust @_ accordingly. In your example, these
two (erroneous) invocations are the same
APR::Bucket->eos_create($data)
APR::Bucket::eos_create("APR::Bucket", $data)
> b) an eos ends only the brigade, isn't it? or it ends the filter?
Ends the *request*. Each brigade / filter invocation
represents only a part of the full request.
>
> 3)- Third, i think $bb should be destroyed instead of cleaned up, am i
> right?
Both the brigade and the buckets within it will be
cleaned up automatically when the connection dies.
It's ok to cleanup/destroy a bucket brigade before that,
but you don't need to worry about this unless you
really want to.
I suggest you try working through the example at
<URL:
http://perl.apache.org/docs/2.0/user/handlers/filters.html
#Bucket_Brigade_based_Output_Filters
>
If you have problems/questions with the documented
examples, report them and the docs will likely improve.
Best wishes.
--
Joe Schaefer
--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html