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)
committerKarolin Seeger <kseeger@samba.org>
Wed, 4 Jan 2012 20:30:32 +0000 (21:30 +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
(cherry picked from commit eb617374a673bb1189dd9b6bccbf3f1d9fb91010)
(cherry picked from commit b3f344b5b52096715eb5670b146f477a67af8245)

source3/lib/recvfile.c

index ea0159642137390a0f7e57a123684e6e63e47581..a1254a2f19d5bc306fe55e84260142f28dbfd0c8 100644 (file)
@@ -213,10 +213,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;
                }