1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

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
This commit is contained in:
Andrew Bartlett 2012-06-05 14:43:24 +10:00
parent 6440720de3
commit 7a723c6b38
3 changed files with 0 additions and 120 deletions

View File

@ -5484,28 +5484,10 @@ ssize_t nwritten = sendfile(tofd, fromfd, &offset, total);
],
samba_cv_HAVE_SENDFILE=yes,samba_cv_HAVE_SENDFILE=no)])
# Try and cope with broken Linux sendfile....
AC_CACHE_CHECK([for broken linux sendfile support],samba_cv_HAVE_BROKEN_LINUX_SENDFILE,[
AC_TRY_LINK([\
#if defined(_FILE_OFFSET_BITS) && (_FILE_OFFSET_BITS == 64)
#undef _FILE_OFFSET_BITS
#endif
#include <sys/sendfile.h>],
[\
int tofd, fromfd;
off_t offset;
size_t total;
ssize_t nwritten = sendfile(tofd, fromfd, &offset, total);
],
samba_cv_HAVE_BROKEN_LINUX_SENDFILE=yes,samba_cv_HAVE_BROKEN_LINUX_SENDFILE=no)])
if test x"$samba_cv_HAVE_SENDFILE" = x"yes"; then
AC_DEFINE(HAVE_SENDFILE,1,[Whether sendfile() is available])
AC_DEFINE(LINUX_SENDFILE_API,1,[Whether linux sendfile() API is available])
AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() should be used])
elif test x"$samba_cv_HAVE_BROKEN_LINUX_SENDFILE" = x"yes"; then
AC_DEFINE(LINUX_BROKEN_SENDFILE_API,1,[Whether (linux) sendfile() is broken])
AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile should be used])
else
AC_MSG_RESULT(no);
fi

View File

@ -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)
/*

View File

@ -961,25 +961,10 @@ main() {
headers='sys/sendfile.h',
msg='Checking for linux sendfile support')
# Try and cope with broken Linux sendfile....
conf.CHECK_CODE('''#if defined(_FILE_OFFSET_BITS) && (_FILE_OFFSET_BITS == 64)
#undef _FILE_OFFSET_BITS
#endif
#include <sys/sendfile.h>
int tofd, fromfd;
off_t offset;
size_t total;
ssize_t nwritten = sendfile(tofd, fromfd, &offset, total);
''',
'_HAVE_BROKEN_LINUX_SENDFILE',
msg='Checking for broken linux sendfile support')
if conf.CONFIG_SET('_HAVE_SENDFILE'):
conf.DEFINE('HAVE_SENDFILE', '1')
conf.DEFINE('LINUX_SENDFILE_API', '1')
conf.DEFINE('WITH_SENDFILE', '1')
elif conf.CONFIG_SET('_HAVE_BROKEN_LINUX_SENDFILE'):
conf.DEFINE('LINUX_BROKEN_SENDFILE_API', '1')
conf.DEFINE('WITH_SENDFILE', '1')
elif (host_os.rfind('freebsd') > -1) or (host_os.rfind('dragonfly') > -1):
conf.CHECK_CODE('''
#include <sys/types.h>