diff options
author | Andrew Bartlett <abartlet@samba.org> | 2012-06-05 14:43:24 +1000 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2012-06-16 02:21:27 +0200 |
commit | 7a723c6b386513ce58fe27469440bfc71debf685 (patch) | |
tree | 47eea60cbe10868bf92eaeb071f22daa2e3c7e97 /source3/lib/sendfile.c | |
parent | 6440720de3123c17baa99b31a3a72f5dba938873 (diff) | |
download | samba-7a723c6b386513ce58fe27469440bfc71debf685.tar.gz |
build: Remove support for non-64bit sendfile()
Some early Linux 2.6 platforms can not handle sendfile and _FILE_OFFSET_BITS == 64
This disables sendfile() on these platforms.
Andrew Bartlett
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Sat Jun 16 02:21:28 CEST 2012 on sn-devel-104
Diffstat (limited to 'source3/lib/sendfile.c')
-rw-r--r-- | source3/lib/sendfile.c | 87 |
1 files changed, 0 insertions, 87 deletions
diff --git a/source3/lib/sendfile.c b/source3/lib/sendfile.c index a9607fa8259..196ef6889b9 100644 --- a/source3/lib/sendfile.c +++ b/source3/lib/sendfile.c @@ -89,93 +89,6 @@ ssize_t sys_sendfile(int tofd, int fromfd, const DATA_BLOB *header, off_t offset return count + hdr_len; } -#elif defined(LINUX_BROKEN_SENDFILE_API) - -/* - * 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 -#endif - -ssize_t sys_sendfile(int tofd, int fromfd, const DATA_BLOB *header, off_t offset, size_t count) -{ - 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 layer catches this - * and uses a normal read. JRA. - */ - - if ((sizeof(off_t) >= 8) && (offset + count > (off_t)0x7FFFFFFF)) { - errno = ENOSYS; - return -1; - } - - /* - * Send the header first. - * Use MSG_MORE to cork the TCP output until sendfile is called. - */ - - if (header) { - hdr_len = header->length; - while (total < hdr_len) { - ret = sys_send(tofd, header->data + total,hdr_len - total, MSG_MORE); - if (ret == -1) - return -1; - total += ret; - } - } - - small_total = (uint32)count; - small_offset = (int32)offset; - - while (small_total) { - int32 nwritten; - do { - nwritten = sendfile(tofd, fromfd, &small_offset, small_total); -#if defined(EWOULDBLOCK) - } while (nwritten == -1 && (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK)); -#else - } while (nwritten == -1 && (errno == EINTR || errno == EAGAIN)); -#endif - if (nwritten == -1) { - if (errno == ENOSYS || errno == EINVAL) { - /* Ok - we're in a world of pain here. We just sent - * the header, but the sendfile failed. We have to - * emulate the sendfile at an upper layer before we - * disable it's use. So we do something really ugly. - * We set the errno to a strange value so we can detect - * this at the upper level and take care of it without - * layer violation. JRA. - */ - errno = EINTR; /* Normally we can never return this. */ - } - return -1; - } - if (nwritten == 0) { - /* - * EOF, return a short read - */ - return hdr_len + (((uint32)count) - small_total); - } - small_total -= nwritten; - } - return count + hdr_len; -} - - #elif defined(SOLARIS_SENDFILE_API) /* |