summaryrefslogtreecommitdiff
path: root/network_io
diff options
context:
space:
mode:
authorJeff Trawick <trawick@apache.org>2000-06-27 20:37:50 +0000
committerJeff Trawick <trawick@apache.org>2000-06-27 20:37:50 +0000
commit8341477b435dfa4d349eee2cdc7e7d1e9076526f (patch)
treed4c38cbf26ad892ede3b5c4fdf6df619c627ac37 /network_io
parentb24ae1ea40f2741c50f6083a2c8481a53336fde7 (diff)
downloadapr-8341477b435dfa4d349eee2cdc7e7d1e9076526f.tar.gz
ap_sendfile() fixes for OS/390 and FreeBSD...
OS/390: just use Victor's AIX flavor... it works for OS/390 as well FreeBSD: account for header bytes when we tell the kernel how much to send; prior to this fix, we wouldn't send as much of the file as desired if headers were provided Note: APR_SO_TIMEOUT issues discussed on new-httpd today will be addressed later. (one step at a time!) git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@60269 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'network_io')
-rw-r--r--network_io/unix/sendrecv.c29
1 files changed, 23 insertions, 6 deletions
diff --git a/network_io/unix/sendrecv.c b/network_io/unix/sendrecv.c
index de5fdfb80..4bcb14468 100644
--- a/network_io/unix/sendrecv.c
+++ b/network_io/unix/sendrecv.c
@@ -306,21 +306,30 @@ ap_status_t ap_sendfile(ap_socket_t * sock, ap_file_t * file,
ap_int32_t flags)
{
off_t nbytes;
- int rv;
+ int rv, i;
struct sf_hdtr headerstruct;
+ size_t bytes_to_send = *len;
+
+ /* On FreeBSD, the number of bytes to send must include the length of
+ * the headers. Don't look at the man page for this :( Instead, look
+ * at the the logic in src/sys/kern/uipc_syscalls::sendfile().
+ */
+
+ for (i = 0; i < hdtr->numheaders; i++) {
+ bytes_to_send += hdtr->headers[i].iov_len;
+ }
headerstruct.headers = hdtr->headers;
headerstruct.hdr_cnt = hdtr->numheaders;
headerstruct.trailers = hdtr->trailers;
headerstruct.trl_cnt = hdtr->numtrailers;
-
/* FreeBSD can send the headers/footers as part of the system call */
do {
rv = sendfile(file->filedes, /* open file descriptor of the file to be sent */
sock->socketdes, /* socket */
*offset, /* where in the file to start */
- (size_t) * len, /* number of bytes to send */
+ bytes_to_send, /* number of bytes to send */
&headerstruct, /* Headers/footers */
&nbytes, /* number of bytes written */
flags /* undefined, set to 0 */
@@ -451,9 +460,17 @@ ap_status_t ap_sendfile(ap_socket_t * sock, ap_file_t * file,
(*len) = rv;
return APR_SUCCESS;
}
-#elif defined(_AIX)
-/* Need another check to make sure the dependencies are checked */
-/* AIX, version 4.3.2 with APAR IX85388, or version 4.3.3 and above */
+#elif defined(_AIX) || defined(__MVS__)
+/* AIX and OS/390 have the same send_file() interface.
+ *
+ * subtle differences:
+ * AIX doesn't update the file ptr but OS/390 does
+ *
+ * availability (correctly determined by autoconf):
+ *
+ * AIX - version 4.3.2 with APAR IX85388, or version 4.3.3 and above
+ * OS/390 - V2R7 and above
+ */
ap_status_t ap_sendfile(ap_socket_t * sock, ap_file_t * file,
ap_hdtr_t * hdtr, ap_off_t * offset, ap_size_t * len,
ap_int32_t flags)