Fix bug #8679 - recvfile code path using splice() on Linux leaves data in the pipe...
authorJeremy Allison <jra@samba.org>
Sun, 25 Dec 2011 05:12:09 +0000 (21:12 -0800)
committerJeremy Allison <jra@samba.org>
Sun, 25 Dec 2011 06:46:38 +0000 (07:46 +0100)
Bug found and fix suggested by Andrew Bartlett.

Autobuild-User: Jeremy Allison <jra@samba.org>
Autobuild-Date: Sun Dec 25 07:46:38 CET 2011 on sn-devel-104

source3/lib/recvfile.c

index 7cbb8a0b92e3587c544230a02e1722451350456e..5d1c0b2c55f85d6b84ec9a24ae60ebecd3c5bab1 100644 (file)
@@ -214,10 +214,9 @@ ssize_t sys_recvfile(int fromfd,
        }
 
  done:
-       if (total_written < count) {
+       if (count) {
                int saved_errno = errno;
-               if (drain_socket(fromfd, count-total_written) !=
-                               count-total_written) {
+               if (drain_socket(fromfd, count) != count) {
                        /* socket is dead. */
                        return -1;
                }