summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--qacp.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/qacp.c b/qacp.c
index b2b9286..ed5a973 100644
--- a/qacp.c
+++ b/qacp.c
@@ -160,7 +160,9 @@ qacp_sendonefile(const char *host, const char *srcfile, const char *destfile)
dlen = sizeof daddr;
outsd = accept(sd, (struct sockaddr *) &daddr, &dlen);
- nbytes = sendfile(outsd, fd, &offset, sb.st_size);
+ do {
+ nbytes = sendfile(outsd, fd, &offset, sb.st_size);
+ } while (nbytes >= 0 && offset < sb.st_size);
if (nbytes == -1 && errno == EINVAL) {
fprintf(stderr, "Falling back to reads\n");
@@ -186,7 +188,7 @@ qacp_sendonefile(const char *host, const char *srcfile, const char *destfile)
}
write(outsd, fallbackbuf, nbytes);
} while (nbytes > 0);
- } else {
+ } else if (nbytes == -1) {
fprintf(stderr, "error: %s\n", strerror(errno));
}
sendone_failure: