httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bojan Smojver <bo...@rexursive.com>
Subject Re: [PATCH]: emulate_sendfile fix [WAS]: File buckets v. core_output_filter
Date Thu, 25 Mar 2004 23:41:09 GMT
On Thu, 2004-03-25 at 06:22, Bill Stoddard wrote:

> My first inclination is to say make sure the file pointer is set to 0 before you send
your brigade down the 
> stack. Would that solve this particular case?
> 
> However, emulate_sendfile() would still be broken in some pathological cases. For example,
consider a handler 
> that wants to open a 10K byte file, and send the last 300 bytes of the file followed
by the first 300 bytes of 
> the file (600 bytes total sent on the network). The handler could build a bucket brigade
with two file 
> buckets, the first bucket with offset 9700, len 300 and the next bucket with offset 0,
len 300.  I see no 
> clean way of making this work.
> 
> Reluctant +1 to your patch.

Thanks for that Bill.

The handler you described might not be as pathological (or unusual) as
one would think at first. For instance, a template processing module
might have rules inside the template that say "send the end first, then
send the beginning, then middle...". Or it might say "send this chunk
multiple times", meaning, go back to the beginning of the file several
times. If those chunks are big, one would want to stick with sendfile()
or similar (i.e. on platforms that don't support it, it would be
emulate_sendfile()). In fact, my own little module does exactly that -
that's how I discovered the problem.

Looking from a different perspective, the purpose of emulate_sendfile()
is to replace sendfile() (or better sendfile_it_all() in core.c), so it
should behave _exactly_ like it's counterpart, only the implementation
should be different, IMHO.

-- 
Bojan


Mime
View raw message