summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2002-09-17 01:00:03 +0000
committerJeremy Allison <jra@samba.org>2002-09-17 01:00:03 +0000
commitf74086ccf09e8157419f7c51490dc31effb6ba20 (patch)
treee3f5bbdd83dfa353486396e3dbf78c08524e4adc /source3/lib
parentad5ab5f5832844dc6eff3f2c72d24eba5e8b4d29 (diff)
downloadsamba-f74086ccf09e8157419f7c51490dc31effb6ba20.tar.gz
samba-f74086ccf09e8157419f7c51490dc31effb6ba20.tar.bz2
samba-f74086ccf09e8157419f7c51490dc31effb6ba20.zip
Attempt to make broken Linux sendfile work.... Still in progress.
Jeremy. (This used to be commit f956a4d29d0d88cd92fac0f0c9f636fc152afe0a)
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/sendfile.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/source3/lib/sendfile.c b/source3/lib/sendfile.c
index 4613cfb864..8bcb9dbd02 100644
--- a/source3/lib/sendfile.c
+++ b/source3/lib/sendfile.c
@@ -76,7 +76,13 @@ ssize_t sys_sendfile(int tofd, int fromfd, const DATA_BLOB *header, SMB_OFF_T of
#elif defined(LINUX_BROKEN_SENDFILE_API)
-#include <sys/sendfile.h>
+/*
+ * We must use explicit 32 bit types here. This code path means Linux
+ * won't do proper 64-bit sendfile. JRA.
+ */
+
+extern int32 sendfile (int out_fd, int in_fd, int32 *offset, uint32 count);
+
#ifndef MSG_MORE
#define MSG_MORE 0x8000
@@ -87,11 +93,13 @@ ssize_t sys_sendfile(int tofd, int fromfd, const DATA_BLOB *header, SMB_OFF_T of
size_t total=0;
ssize_t ret;
ssize_t hdr_len = 0;
+ uint32 small_total = 0;
+ int32 small_offset;
/*
* Fix for broken Linux 2.4 systems with no working sendfile64().
* If the offset+count > 2 GB then pretend we don't have the
- * system call sendfile at all. The upper later catches this
+ * system call sendfile at all. The upper layer catches this
* and uses a normal read. JRA.
*/
@@ -115,17 +123,19 @@ ssize_t sys_sendfile(int tofd, int fromfd, const DATA_BLOB *header, SMB_OFF_T of
}
}
- total = count;
- while (total) {
- ssize_t nwritten;
+ small_total = (uint32)count;
+ small_offset = (int32)offset;
+
+ while (small_total) {
+ int32 nwritten;
do {
- nwritten = sendfile(tofd, fromfd, &offset, total);
+ nwritten = sendfile(tofd, fromfd, &small_offset, small_total);
} while (nwritten == -1 && errno == EINTR);
if (nwritten == -1)
return -1;
if (nwritten == 0)
return -1; /* I think we're at EOF here... */
- total -= nwritten;
+ small_total -= nwritten;
}
return count + hdr_len;
}