summaryrefslogtreecommitdiff
path: root/source3/lib/sendfile.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2009-01-13 13:02:44 -0800
committerJeremy Allison <jra@samba.org>2009-01-13 13:02:44 -0800
commit0f450623c5e73b941ced136ba7160bf6554a21ce (patch)
tree5232d14f1f9dcf737a12a8d91e7d7de0a677ce93 /source3/lib/sendfile.c
parent83c3b2809636cab704a54c2d699a907c6d07d199 (diff)
downloadsamba-0f450623c5e73b941ced136ba7160bf6554a21ce.tar.gz
samba-0f450623c5e73b941ced136ba7160bf6554a21ce.tar.bz2
samba-0f450623c5e73b941ced136ba7160bf6554a21ce.zip
Fix bug noticed by Volker - if sendfile returns zero then
we might have to handle a short send by filling with zeros. Jeremy.
Diffstat (limited to 'source3/lib/sendfile.c')
-rw-r--r--source3/lib/sendfile.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/source3/lib/sendfile.c b/source3/lib/sendfile.c
index fb10cae2aa..59a18ce6e1 100644
--- a/source3/lib/sendfile.c
+++ b/source3/lib/sendfile.c
@@ -78,8 +78,12 @@ ssize_t sys_sendfile(int tofd, int fromfd, const DATA_BLOB *header, SMB_OFF_T of
}
return -1;
}
- if (nwritten == 0)
- return -1; /* I think we're at EOF here... */
+ if (nwritten == 0) {
+ /*
+ * EOF, return a short read
+ */
+ return hdr_len + (count - total);
+ }
total -= nwritten;
}
return count + hdr_len;
@@ -156,8 +160,12 @@ ssize_t sys_sendfile(int tofd, int fromfd, const DATA_BLOB *header, SMB_OFF_T of
}
return -1;
}
- if (nwritten == 0)
- return -1; /* I think we're at EOF here... */
+ if (nwritten == 0) {
+ /*
+ * EOF, return a short read
+ */
+ return hdr_len + (((uint32)count) - small_total);
+ }
small_total -= nwritten;
}
return count + hdr_len;