The branch, master has been updated
       via  e1459a237948c2c9b7da94e4ba0acc79b1cd8eca (commit)
      from  59f8c1d98a53b01a32883da0662ce33cadd45419 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit e1459a237948c2c9b7da94e4ba0acc79b1cd8eca
Author: Volker Lendecke <[email protected]>
Date:   Wed Jan 7 10:39:34 2009 +0000

    Several fixes to our use of splice
    
    The splice manpage explicitly requires loff_t as offset. Copy "offset" 
there.
    Probably not required, but I wanted to make sure it's as required.
    
    Splice blocks with large buffers. For me it worked with 16k and blocked with
    32k and beyond. It would be nice to see a clarification in the manpage of
    splice for this behaviour.
    
    Splice if used with an offset increments the offset. From the manpage this 
was
    at least not entirely obvious :-)
    
    I haven't yet activated this (try_splice_call ist still false by default), 
it
    needs more testing.
    
    Volker

-----------------------------------------------------------------------

Summary of changes:
 source3/lib/recvfile.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/lib/recvfile.c b/source3/lib/recvfile.c
index c9710a7..ea01596 100644
--- a/source3/lib/recvfile.c
+++ b/source3/lib/recvfile.c
@@ -148,6 +148,7 @@ ssize_t sys_recvfile(int fromfd,
        static int pipefd[2] = { -1, -1 };
        static bool try_splice_call = false;
        size_t total_written = 0;
+       loff_t splice_offset = offset;
 
        DEBUG(10,("sys_recvfile: from = %d, to = %d, "
                "offset=%.0f, count = %lu\n",
@@ -180,7 +181,8 @@ ssize_t sys_recvfile(int fromfd,
        while (count > 0) {
                int nread, to_write;
 
-               nread = splice(fromfd, NULL, pipefd[1], NULL, count, 0);
+               nread = splice(fromfd, NULL, pipefd[1], NULL,
+                              MIN(count, 16384), SPLICE_F_MOVE);
                if (nread == -1) {
                        if (errno == EINTR) {
                                continue;
@@ -197,12 +199,12 @@ ssize_t sys_recvfile(int fromfd,
                to_write = nread;
                while (to_write > 0) {
                        int thistime;
-                       thistime = splice(pipefd[0], NULL, tofd, &offset,
-                                         to_write, 0);
+                       thistime = splice(pipefd[0], NULL, tofd,
+                                         &splice_offset, to_write,
+                                         SPLICE_F_MOVE);
                        if (thistime == -1) {
                                goto done;
                        }
-                       offset += thistime;
                        to_write -= thistime;
                }
 


-- 
Samba Shared Repository

Reply via email to