You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Dave Viner <da...@pobox.com> on 2006/10/30 19:49:06 UTC
EnableSendfile and $r->sendfile
I'm trying to understand the full effect of the EnableSendfile
directive. If I set the directive to 'Off', what happens when I
invoke $r->sendfile($myfile) ??
My hope is that the $r->sendfile will simply use mechanism other than
sendfile() to read/send the given file (maybe allocate a buffer, read
in file to buffer, send buffer, repeat until file is eof()... or
something similar). But I've looked in the source, but I can't seem
to convince myself that this will actually happen.
Thanks
dave viner
Re: EnableSendfile and $r->sendfile
Posted by "Philippe M. Chiasson" <go...@ectoplasm.org>.
On 30-Oct-06, at 10:49 AM, Dave Viner wrote:
> I'm trying to understand the full effect of the EnableSendfile
> directive. If I set the directive to 'Off', what happens when I
> invoke $r->sendfile($myfile) ??
>
> My hope is that the $r->sendfile will simply use mechanism other
> than sendfile() to read/send the given file (maybe allocate a
> buffer, read in file to buffer, send buffer, repeat until file is
> eof()... or something similar). But I've looked in the source, but
> I can't seem to convince myself that this will actually happen
$r->sendfile($myfile) ends up calling ap_send_fd()
ap_send_fd() checks the setting of EnableSendfile, and if it's on AND
APR_HAS_SENDFILE was detected,
it then calls apr_file_open with the APR_SENDFILE_ENABLED flag
See here http://apr.apache.org/docs/apr/group__apr__file__io.html#ga3
But it's basically an advisory flag, saying please try and use
sendfile(), but nothing is guaranteed. In any case,
it will always fallback to something sane, sending the file one way
or another.