Apache (really apr, I guess) attempts to be clever and detect the version of FreeBSD at runtime; this information is then used to determine whether or not the length of headers needs to be added to the length passed to sendfile. This is to work around a bug present before 4.6-stable which required the length to be passed. Anyway, this entire check is unneeded. As part of the fix, alfred perlstein created a new sendfile syscall; any program compiled with < 4.6 header files will use the old syscall which requires the header length to be added in, and any program compiled with > 4.6 will call the new syscall. Hence, only a compile time check should be done. The current runtime test is basically one huge no-op. Patch will be attached in a second.
Patch is available from: http://www.silby.com/patches/raw/patch-sendfile_fix This should apply to any 2.x version of apache, I believe.
+1 Tested on FreeBSD 5.2 Also Moving this to the APR Project. (Not an Apache Bug)
Has a binary built on >4.6 been tested on <4.6?
Yes, a > 4.6 binary dies when run on pre-4.6, as it uses a syscall unknown to the pre-4.6 kernel. It would be possible to rig apache so that it actually knew which sendfile (new or old) to use so that post-4.6 binaries would work on older kernels, but there's really no reason to bother.
Yes, we shouldn't care if a binary built on OS level x fails when run on lower level of the OS. Has anybody tested this on older FreeBSD? (I remember the pain when www.apache.org got screwed by picking up a FreeBSD update that changed the sendfile() semantics. There was no compatibility sendfile() interface at the time to make the old Apache code work. Maybe it is only some intermediate maintenance levels of 4.5(?) that will break without the code in cvs today???)
Yeah, sorry, I meant the other way round: has a binary built with this change on old FreeBSD been tested to DTRT on new FreeBSD too.
I have not tested a pre-4.6 binary, as I do not have any pre-4.6 machines sitting around. I assume that this was well tested when the osendfile comaptibility shim was added.
Do we need to test for a Binary Built on <4.6 working on >=4.6? If not, is there any reason that we cannot commit this patch? If this patch is applied, we would also fix the sendfile detection on DragonFly BSD (Bug #29858) -Paul Querna
Using APR Built On FreeBSD 4.5(thanks VMWare) and the supplied patch, All Tests pass. (including ./sendilfe server &; ./sendfile client timeout,nonblocking,blocking) Taking the APR built on FreeBSD 4.5, to a 5.2-CURRENT box, the same tests all pass, including the sendfile tests. There is no reason to not include the patch now.
is there anything keeping this patch from being committed? the last comment is from four months ago and indicates that testing on the various versions of freebsd worked out fine, but as far as I can tell the version in trunk is still using sysctl to figure this stuff out at runtime.
I will commit it this weekend to TRUNK. -Paul Querna
Committed to trunk as svn revision 106850.
(In reply to comment #12) > Committed to trunk as svn revision 106850. Thanks! Is there an expected date when this fix also gets backported to release branches? The fix also (partially) resolves Bug 29858.
I wasn't planning to backport this to apr-0.9.x or the 1.0.x branch. I would prefer to relese this as 1.1.0. (hopefully, that will happen sooner, rather than later). Opinion from others?
This fix was released in 1.1.0