diff options
author | Jeremy Allison <jra@samba.org> | 2007-10-30 16:22:24 -0700 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2007-10-30 16:22:24 -0700 |
commit | c3250149e12338fac5093991b385ad2807c92d1f (patch) | |
tree | fa1e5387fb10d02b1f09da59fc20d7a8520e65fc /source3/lib/recvfile.c | |
parent | 4367f4b4d4ce075f3fe8e88e68dbda47e2252349 (diff) | |
download | samba-c3250149e12338fac5093991b385ad2807c92d1f.tar.gz samba-c3250149e12338fac5093991b385ad2807c92d1f.tar.xz samba-c3250149e12338fac5093991b385ad2807c92d1f.zip |
Add new parameter, "min receivefile size" (by default set
to zero). If non-zero, writeX calls greater than this
value will be left in the socket buffer for later handling
with recvfile (or userspace equivalent). Definition of
recvfile for your system is left as an exercise for
the reader (I'm working on getting splice working :-).
Jeremy.
(This used to be commit 11c03b75ddbcb6e36b231bb40a1773d1c550621c)
Diffstat (limited to 'source3/lib/recvfile.c')
-rw-r--r-- | source3/lib/recvfile.c | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/source3/lib/recvfile.c b/source3/lib/recvfile.c index cd9fb12716..9d77f94a29 100644 --- a/source3/lib/recvfile.c +++ b/source3/lib/recvfile.c @@ -125,13 +125,49 @@ static ssize_t default_sys_recvfile(int fromfd, } #if defined(HAVE_SPLICE_SYSCALL) + +#ifdef JRA_SPLICE_TEST +#include <linux/unistd.h> +#include <sys/syscall.h> + +#define __NR_splice 313 +_syscall6( long, splice, + int, fromfd, + loff_t *, fromoffset, + int, tofd, + loff_t *, tooffset, + size_t, count, + unsigned int, flags); +#endif + ssize_t sys_recvfile(int fromfd, int tofd, SMB_OFF_T offset, size_t count) { - errno = ENOSYS - return -1; + size_t total = 0; + + if (count == 0) { + return 0; + } + + while (total < count) { + ssize_t ret = splice(fromfd, + NULL, + tofd, + &offset, + count, + 0); + if (ret == -1) { + if (errno != EINTR) { + return -1; + } + continue; + } + total += ret; + count -= ret; + } + return total; } #else |