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. > > When I pass this to output filters in my handler with > ap_pass_brigade(r->output_filters,bb), I'm getting completely random > output from. In other words, offsets of FILE buckets are completely > screwed or buckets down show up at all. > > If I, however, build a brigade like this: > > FILE - FLUSH - POOL - FILE - FLUSH - POOL - FILE - FLUSH - EOS > > then it all works fine. Also, if the good parts of my file are below 256 > bytes (or if I increase AP_MIN_SENDFILE_BYTES above the threshold), > there are no problems at all. > > I was testing this all this on 2.0.46, Red Hat Linux 9. Has anyone else > observed anything like that? Has anything like that been fixed lately? > > Or am I simply doing something really stupid... -- Bojan
diff -ruN httpd-2.0.49-vanilla/server/core.c httpd-2.0.49/server/core.c --- httpd-2.0.49-vanilla/server/core.c 2004-03-09 09:54:20.000000000 +1100 +++ httpd-2.0.49/server/core.c 2004-03-22 18:56:29.000000000 +1100 @@ -2975,7 +2975,7 @@ } /* Seek the file to 'offset' */ - if (offset != 0 && rv == APR_SUCCESS) { + if (offset >= 0 && rv == APR_SUCCESS) { rv = apr_file_seek(fd, APR_SET, &offset); }