summaryrefslogtreecommitdiff
path: root/source3
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
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')
-rw-r--r--source3/acconfig.h1
-rwxr-xr-xsource3/configure42
-rw-r--r--source3/configure.in4
-rw-r--r--source3/include/config.h.in1
-rw-r--r--source3/lib/sendfile.c24
-rw-r--r--source3/smbd/reply.c2
6 files changed, 48 insertions, 26 deletions
diff --git a/source3/acconfig.h b/source3/acconfig.h
index 141c59bfed..8ca44f7aba 100644
--- a/source3/acconfig.h
+++ b/source3/acconfig.h
@@ -226,3 +226,4 @@
#undef HAVE_SENDFILE64
#undef LINUX_SENDFILE_API
#undef LINUX_BROKEN_SENDFILE_API
+#undef WITH_SENDFILE
diff --git a/source3/configure b/source3/configure
index 8e4b1d2961..56ac8ef274 100755
--- a/source3/configure
+++ b/source3/configure
@@ -13931,6 +13931,10 @@ EOF
#define LINUX_SENDFILE_API 1
EOF
+ cat >> confdefs.h <<\EOF
+#define WITH_SENDFILE 1
+EOF
+
elif test x"$samba_cv_HAVE_SENDFILE" = x"yes"; then
cat >> confdefs.h <<\EOF
#define HAVE_SENDFILE 1
@@ -13940,15 +13944,19 @@ EOF
#define LINUX_SENDFILE_API 1
EOF
- elif test x"$samba_cv_HAVE_BROKEN_LINUX_SENDFILE" = x"yes"; then
- cat >> confdefs.h <<\EOF
-#define HAVE_SENDFILE 1
+ cat >> confdefs.h <<\EOF
+#define WITH_SENDFILE 1
EOF
+ elif test x"$samba_cv_HAVE_BROKEN_LINUX_SENDFILE" = x"yes"; then
cat >> confdefs.h <<\EOF
#define LINUX_BROKEN_SENDFILE_API 1
EOF
+ cat >> confdefs.h <<\EOF
+#define WITH_SENDFILE 1
+EOF
+
else
echo "$ac_t""no" 1>&6;
fi
@@ -13975,7 +13983,7 @@ fi
# (WINBIND_STARGETS) and shared libraries (WINBIND_LTARGETS).
echo $ac_n "checking whether to build winbind""... $ac_c" 1>&6
-echo "configure:13979: checking whether to build winbind" >&5
+echo "configure:13987: checking whether to build winbind" >&5
# Initially, the value of $host_os decides whether winbind is supported
@@ -14071,20 +14079,20 @@ fi
# [#include <pwd.h>])
echo $ac_n "checking whether struct passwd has pw_comment""... $ac_c" 1>&6
-echo "configure:14075: checking whether struct passwd has pw_comment" >&5
+echo "configure:14083: checking whether struct passwd has pw_comment" >&5
if eval "test \"`echo '$''{'samba_cv_passwd_pw_comment'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 14081 "configure"
+#line 14089 "configure"
#include "confdefs.h"
#include <pwd.h>
int main() {
struct passwd p; p.pw_comment;
; return 0; }
EOF
-if { (eval echo configure:14088: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:14096: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
samba_cv_passwd_pw_comment=yes
else
@@ -14109,20 +14117,20 @@ fi
# [#include <pwd.h>])
echo $ac_n "checking whether struct passwd has pw_age""... $ac_c" 1>&6
-echo "configure:14113: checking whether struct passwd has pw_age" >&5
+echo "configure:14121: checking whether struct passwd has pw_age" >&5
if eval "test \"`echo '$''{'samba_cv_passwd_pw_age'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 14119 "configure"
+#line 14127 "configure"
#include "confdefs.h"
#include <pwd.h>
int main() {
struct passwd p; p.pw_age;
; return 0; }
EOF
-if { (eval echo configure:14126: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:14134: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
samba_cv_passwd_pw_age=yes
else
@@ -14161,7 +14169,7 @@ fi
if test x"$INCLUDED_POPT" != x"yes"; then
echo $ac_n "checking for poptGetContext in -lpopt""... $ac_c" 1>&6
-echo "configure:14165: checking for poptGetContext in -lpopt" >&5
+echo "configure:14173: checking for poptGetContext in -lpopt" >&5
ac_lib_var=`echo popt'_'poptGetContext | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -14169,7 +14177,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lpopt $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 14173 "configure"
+#line 14181 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -14180,7 +14188,7 @@ int main() {
poptGetContext()
; return 0; }
EOF
-if { (eval echo configure:14184: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:14192: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -14204,7 +14212,7 @@ fi
fi
echo $ac_n "checking whether to use included popt""... $ac_c" 1>&6
-echo "configure:14208: checking whether to use included popt" >&5
+echo "configure:14216: checking whether to use included popt" >&5
if test x"$INCLUDED_POPT" = x"yes"; then
echo "$ac_t""yes" 1>&6
BUILD_POPT='$(POPT_OBJS)'
@@ -14243,16 +14251,16 @@ fi
# final configure stuff
echo $ac_n "checking configure summary""... $ac_c" 1>&6
-echo "configure:14247: checking configure summary" >&5
+echo "configure:14255: checking configure summary" >&5
if test "$cross_compiling" = yes; then
echo "configure: warning: cannot run when cross-compiling" 1>&2
else
cat > conftest.$ac_ext <<EOF
-#line 14252 "configure"
+#line 14260 "configure"
#include "confdefs.h"
#include "${srcdir-.}/tests/summary.c"
EOF
-if { (eval echo configure:14256: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:14264: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
echo "$ac_t""yes" 1>&6
else
diff --git a/source3/configure.in b/source3/configure.in
index 76dc380c13..8f3a06b0cd 100644
--- a/source3/configure.in
+++ b/source3/configure.in
@@ -2710,12 +2710,14 @@ samba_cv_HAVE_BROKEN_LINUX_SENDFILE=yes,samba_cv_HAVE_BROKEN_LINUX_SENDFILE=no)]
if test x"$samba_cv_HAVE_SENDFILE64" = x"yes"; then
AC_DEFINE(HAVE_SENDFILE64)
AC_DEFINE(LINUX_SENDFILE_API)
+ AC_DEFINE(WITH_SENDFILE)
elif test x"$samba_cv_HAVE_SENDFILE" = x"yes"; then
AC_DEFINE(HAVE_SENDFILE)
AC_DEFINE(LINUX_SENDFILE_API)
+ AC_DEFINE(WITH_SENDFILE)
elif test x"$samba_cv_HAVE_BROKEN_LINUX_SENDFILE" = x"yes"; then
- AC_DEFINE(HAVE_SENDFILE)
AC_DEFINE(LINUX_BROKEN_SENDFILE_API)
+ AC_DEFINE(WITH_SENDFILE)
else
AC_MSG_RESULT(no);
fi
diff --git a/source3/include/config.h.in b/source3/include/config.h.in
index 3c56845174..119df4dd5b 100644
--- a/source3/include/config.h.in
+++ b/source3/include/config.h.in
@@ -292,6 +292,7 @@
#undef HAVE_SENDFILE64
#undef LINUX_SENDFILE_API
#undef LINUX_BROKEN_SENDFILE_API
+#undef WITH_SENDFILE
/* The number of bytes in a int. */
#undef SIZEOF_INT
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;
}
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index 878e21f4c2..45704b9264 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -1692,7 +1692,7 @@ int send_file_readX(connection_struct *conn, char *inbuf,char *outbuf,int length
ssize_t nread = -1;
char *data = smb_buf(outbuf);
-#if defined(WITH_SENDFILE) && defined(HAVE_SENDFILE)
+#if defined(WITH_SENDFILE)
/*
* We can only use sendfile on a non-chained packet and on a file
* that is exclusively oplocked.