]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
First cut at adding a sendfile API to IOL. Eventually need to move iol_socket
authorBill Stoddard <stoddard@apache.org>
Tue, 2 Nov 1999 14:30:23 +0000 (14:30 +0000)
committerBill Stoddard <stoddard@apache.org>
Tue, 2 Nov 1999 14:30:23 +0000 (14:30 +0000)
into APR...

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@84089 13f79535-47bb-0310-9956-ffa450edef68

modules/http/http_protocol.c
os/win32/os.h
server/mpm/winnt/mpm_winnt.c

index 57073b43b84eb8dce747edf854eb53d35985e027..2032df47fd87ba0a3c4593abacc43e10cd00722b 100644 (file)
@@ -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)
index 6e026ed912d089d650f2a2d0ba30c434d1f0db73..4b3593929bc2837fec2da2149691198f36e9f50c 100644 (file)
 #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;
index 699f59da642065370abc04c3765dfc2fb698df23..a191a5218384bfd2ed2daa1a00950947ae17a154 100644 (file)
@@ -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;