From 0f450623c5e73b941ced136ba7160bf6554a21ce Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 13 Jan 2009 13:02:44 -0800 Subject: Fix bug noticed by Volker - if sendfile returns zero then we might have to handle a short send by filling with zeros. Jeremy. --- source3/lib/sendfile.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'source3/lib/sendfile.c') 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; -- cgit