[SCM] Samba Shared Repository - branch v3-2-stable updated -
release-3-2-0rc1-1-ga9d954e
Karolin Seeger
kseeger at samba.org
Mon May 26 09:25:16 GMT 2008
The branch, v3-2-stable has been updated
via a9d954e30eca9f181a402ad29669e2b42a27b133 (commit)
from 874bc18a992999af5413d3c17d674108a3078f67 (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-2-stable
- Log -----------------------------------------------------------------
commit a9d954e30eca9f181a402ad29669e2b42a27b133
Author: Jeremy Allison <jra at samba.org>
Date: Tue May 6 15:46:34 2008 -0700
Enable tests for splice on Linux. Add a static (vl, I hate this)
so we can detect broken Linux recvfile splice and correctly fall
back.
Karolin, I think this should be pulled into 3.2-stable even
though it's a feature change as otherwise there's no way for
3.2 to use recvfile zerocopy, which is an advertised feature.
Others please comment.
Jeremy.
(cherry picked from commit bad2c3f1c817a94b7638bbf6456ff862829aed76)
-----------------------------------------------------------------------
Summary of changes:
source/configure.in | 20 ++++++++++++++++++++
source/lib/recvfile.c | 21 +++++++++++++++++++--
2 files changed, 39 insertions(+), 2 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source/configure.in b/source/configure.in
index a9d22af..671ed63 100644
--- a/source/configure.in
+++ b/source/configure.in
@@ -5591,6 +5591,26 @@ if test x"$samba_cv_HAVE_POSIX_FADVISE" = x"yes"; then
[Whether posix_fadvise is available])
fi
+############################################
+# See if we have the Linux splice syscall.
+
+AC_CACHE_CHECK([for Linux splice],
+ samba_cv_HAVE_LINUX_SPLICE,[
+ AC_TRY_LINK([
+#if defined(HAVE_UNISTD_H)
+#include <unistd.h>
+#endif
+#include <fcntl.h>],
+ [long ret = splice(0,0,1,0,400,0);],
+ samba_cv_HAVE_LINUX_SPLICE=yes,
+ samba_cv_HAVE_LINUX_SPLICE=no)])
+
+if test x"$samba_cv_HAVE_LINUX_SPLICE" = x"yes"; then
+ AC_DEFINE(HAVE_LINUX_SPLICE,1,
+ [Whether Linux splice is available])
+fi
+
+AC_HAVE_DECL(splice, [#include <fcntl.h>])
#################################################
diff --git a/source/lib/recvfile.c b/source/lib/recvfile.c
index 07c1f68..513742c 100644
--- a/source/lib/recvfile.c
+++ b/source/lib/recvfile.c
@@ -129,7 +129,7 @@ static ssize_t default_sys_recvfile(int fromfd,
return (ssize_t)total_written;
}
-#if defined(HAVE_SPLICE_SYSCALL)
+#if defined(HAVE_LINUX_SPLICE)
/*
* Try and use the Linux system call to do this.
@@ -139,11 +139,13 @@ static ssize_t default_sys_recvfile(int fromfd,
* from the network in the case of return != -1.
*/
+
ssize_t sys_recvfile(int fromfd,
int tofd,
SMB_OFF_T offset,
size_t count)
{
+ static bool try_splice_call = true;
size_t total_written = 0;
DEBUG(10,("sys_recvfile: from = %d, to = %d, "
@@ -155,6 +157,20 @@ ssize_t sys_recvfile(int fromfd,
return 0;
}
+ /*
+ * Older Linux kernels have splice for sendfile,
+ * but it fails for recvfile. Ensure we only try
+ * this once and always fall back to the userspace
+ * implementation if recvfile splice fails. JRA.
+ */
+
+ if (!try_splice_call) {
+ return default_sys_recvfile(fromfd,
+ tofd,
+ offset,
+ count);
+ }
+
while (total_written < count) {
ssize_t ret = splice(fromfd,
NULL,
@@ -165,7 +181,8 @@ ssize_t sys_recvfile(int fromfd,
if (ret == -1) {
if (errno != EINTR) {
if (total_written == 0 &&
- errno == EBADF || errno == EINVAL) {
+ (errno == EBADF || errno == EINVAL)) {
+ try_splice_call = false;
return default_sys_recvfile(fromfd,
tofd,
offset,
--
Samba Shared Repository
More information about the samba-cvs
mailing list