I think I finally found the culprit. At first I thought it was the core_output_filter, but it turns out that emulate_sendfile (incorrectly) assumes that it is at the beginning of the file even when it's not.
The attached patch works here when I have the combo of buckets as described below. The patch is against 2.0.49.
On Thu, 2003-08-07 at 21:49, Bojan Smojver wrote:
Greetings everyone, it has been a while since I posted my ramblings about mod_logio... Anyway, it's that time of the year again :-)
I'm working on a new module and I have hit a strange problem in relation to core_output_filter, which is as far as I can see affecting my output.
Let's say I have a file that contains 300 bytes of something I'm interested in, then 10 bytes of rubbish, then 300 bytes of good stuff again and so on. The reason I'm picking 300 bytes here is because this number is greater than AP_MIN_SENDFILE_BYTES, which is 256.
So, I build up a brigade that looks like this:
FILE - POOL - FILE - POOL - FILE - EOS
The POOL buckets contains something useful instead of 10 bytes of rubbish that I would normally find in the file. The file buckets are chunks of the same file that I'm interested in.
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.
Bill