You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Bill Stoddard <st...@raleigh.ibm.com> on 1999/11/02 00:16:10 UTC

sendfile API

I'd like to see Apache 2.0 have support for the sendfile API. Here's what
I'm thinking...

Create a new feature macro, HAVE_SENDFILE that is defined for operating
systems that support a sendfile API.  The primary place where this would be
used is in the ap_send_fd() code in http_protocol.c. ap_send_fd() would look
something like this:

ap_send_fd(...) {
#ifdef HAVE_SENDFILE
    ap_sendfile(...);
#else
    ap_send_fd_length(...);
#endif
}

The parameters to ap_sendfile would be thus...

    ap_status_t     ap_send_file(ap_iol *fd, ap_file_t *fd, long size, const
char *header, long hdrlen, int flags);

Where
    ap_iol - iol_layer pointer
    fd - the file to send
    size - the size of the file
    header  - pointer to a buffer containing the headers to be sent before
the data
    headerLen - length of the header buffer to send
    flags - to be determined (e.g., flags whether to reuse the socket or
not, etc.)

I only included a header buffer because it seems to catch all the most
common cases. We could be more generic and include an io_vec for header
information; could include an io_vec for trailers as well, but that just
seems to be overkill.

Opinions? If I don;t hear anything, I'll commit the code I have working
under Windows and we'll go from there.

Bill




Re: sendfile API

Posted by Bill Stoddard <st...@raleigh.ibm.com>.
> ap_send_fd(...) {
> #ifdef HAVE_SENDFILE
>     ap_sendfile(...);
ap_sendfile() should be iol_sendfile()...

> #else
>     ap_send_fd_length(...);
> #endif
> }



Re: sendfile API

Posted by Bill Stoddard <st...@raleigh.ibm.com>.
> On Mon, 1 Nov 1999, Bill Stoddard wrote:
>
> > I only included a header buffer because it seems to catch all the most
> > common cases. We could be more generic and include an io_vec for header
> > information; could include an io_vec for trailers as well, but that just
> > seems to be overkill.
>
> please do the iovecs... isn't that what NT supports?  linux supports it as
> well (via TCP_CORK and writev)... it's only hpux i think that's got the
> silly single buffer limitations.
>
> please do the trailers... just so that we have them for when we want them
> later.  (i.e. consider an imap server which wants to use sendfile to send
> message bodies/attachments, it needs a trailer).
>
> Dean
>
Okay, will do.

Bill


Re: sendfile API

Posted by Dean Gaudet <dg...@arctic.org>.

On Mon, 1 Nov 1999, Bill Stoddard wrote:

> I only included a header buffer because it seems to catch all the most
> common cases. We could be more generic and include an io_vec for header
> information; could include an io_vec for trailers as well, but that just
> seems to be overkill.

please do the iovecs... isn't that what NT supports?  linux supports it as
well (via TCP_CORK and writev)... it's only hpux i think that's got the
silly single buffer limitations.

please do the trailers... just so that we have them for when we want them
later.  (i.e. consider an imap server which wants to use sendfile to send
message bodies/attachments, it needs a trailer).

Dean