From: Bill Stoddard Date: Tue, 2 Nov 1999 14:30:23 +0000 (+0000) Subject: First cut at adding a sendfile API to IOL. Eventually need to move iol_socket X-Git-Tag: 1.3.10~197 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ee53e27fb69444f44b89126accf478af1e2d7af2;p=thirdparty%2Fapache%2Fhttpd.git First cut at adding a sendfile API to IOL. Eventually need to move iol_socket into APR... git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@84089 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/http/http_protocol.c b/modules/http/http_protocol.c index 57073b43b84..2032df47fd8 100644 --- a/modules/http/http_protocol.c +++ b/modules/http/http_protocol.c @@ -2008,7 +2008,23 @@ API_EXPORT(int) ap_discard_request_body(request_rec *r) */ API_EXPORT(long) ap_send_fd(ap_file_t *fd, request_rec *r) { - return ap_send_fd_length(fd, r, -1); + ap_ssize_t len = r->finfo.st_size; +#ifdef HAVE_SENDFILE + ap_bflush(r->connection->client); + if (ap_get_filesize(&len, fd) != APR_SUCCESS) { + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r, + "ap_send_fd: ap_get_filesize failed."); + return 0; + } + if (iol_sendfile(r->connection->client->iol, fd, len, + NULL, 0, 0) != APR_SUCCESS) { + ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r, + "ap_send_fd: iol_sendfile failed."); + } +#else + len = ap_send_fd_length(fd, r, -1); +#endif + return len; } API_EXPORT(long) ap_send_fd_length(ap_file_t *fd, request_rec *r, long length) diff --git a/os/win32/os.h b/os/win32/os.h index 6e026ed912d..4b3593929bc 100644 --- a/os/win32/os.h +++ b/os/win32/os.h @@ -108,6 +108,7 @@ #define MULTITHREAD #define HAVE_CANONICAL_FILENAME #define HAVE_DRIVE_LETTERS +#define HAVE_SENDFILE typedef int uid_t; typedef int gid_t; typedef int pid_t; diff --git a/server/mpm/winnt/mpm_winnt.c b/server/mpm/winnt/mpm_winnt.c index 699f59da642..a191a521838 100644 --- a/server/mpm/winnt/mpm_winnt.c +++ b/server/mpm/winnt/mpm_winnt.c @@ -299,7 +299,7 @@ static int AMCSocketInitialize(void) return (s_iInitCount); /* s_iInitCount == 0. Do the initailization */ - iVersionRequested = MAKEWORD(1, 1); + iVersionRequested = MAKEWORD(2, 0); err = WSAStartup((WORD) iVersionRequested, &wsaData); if (err) { s_iInitCount = -1;