perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Philippe M. Chiasson" <go...@cpan.org>
Subject Re: [patch] C implementation of $r->content + rfc on the name
Date Tue, 20 May 2003 06:36:53 GMT
On Tue, 2003-05-20 at 06:57, Stas Bekman wrote:
> Philippe M. Chiasson wrote:
> 
> >>>Why not implement your own pflatten equivalent
> >>>
> >>>apr_status_t modperl_brigade_sv_flatten(pTHX_ apr_bucket_brigade *bb, SV
> >>>*sv) {
> >>>                                               
> >>>{
> >>>    apr_off_t actual;
> >>>    apr_size_t total;
> >>>    apr_status_t rv;
> >>>
> >>>    /* XXX: 1: triggers reads on unknown size buckets */
> >>>    apr_brigade_length(bb, 1, &actual);
> >>>    total = (apr_size_t)actual;
> >>>    
> >>>    return apr_brigade_flatten(bb, SvGROW(sv, total), &total);
> >>>}
> >>>
> >>>Something like that, to at least avoid allocating the storage twice.
> >>
> >>right, I've missed the _length API :(
> > 
> > 
> > And it should be used carefully, as to figure out the length of a
> > brigade, all buckets with unknown length (-1), i.e. network buckets,
> > will have to be read first (i.e. network reads) before their size can be
> > assessed. That's why there is a 1/0 flag in _length to specify if you
> > want the 'exact' size, or just the size of what's known.
> 
> I thought that since this is an input stream, chances are that 99.9% of the 
> traffic will be plain HEAP buckets. POST data is always coming fully attached. 
> So it should be safe to force using the length.

I didn't check the code, but I do seem to remember that
core_input_filter will insert a socket bucket (the tcp connection) in
the input chain.

And I would expect that callign apr_brigade_length on that with the '1'
flag could potentially result in a blocking call to apr_bucket_read if
apr_brigade_length is reading in APR_BLOCK_READ mode.

It does make sense in a way. If the data is coming from a slow client,
you'll need to read it all in before you can figure out what it's size
is.
> __________________________________________________________________
> Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
> http://stason.org/     mod_perl Guide ---> http://perl.apache.org
> mailto:stas@stason.org http://use.perl.org http://apacheweek.com
> http://modperlbook.org http://apache.org   http://ticketmaster.com
-- 
-- -----------------------------------------------------------------------------
Philippe M. Chiasson /gozer\@(cpan|ectoplasm)\.org/ 88C3A5A5 (122FF51B/C634E37B)
http://gozer.ectoplasm.org/    F9BF E0C2 480E 7680 1AE5 3631 CB32 A107 88C3 A5A5
Q: It is impossible to make anything foolproof because fools are so ingenious.
perl -e'$$=\${gozer};{$_=unpack(P7,pack(L,$$));/^JAm_pH\n$/&&print||$$++&&redo}'

Mime
View raw message