summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNate Straz <nstraz@redhat.com>2006-11-16 04:56:46 +0000
committerNathan Straz <nstraz@redhat.com>2008-09-23 09:37:46 -0400
commitaaf5cb39094bf87ac895210c4cf7f27d4483a3b9 (patch)
treee59ef496a2927ccfcab76b9c360045855a27a452
parent9fc82fc82e7248a598b8c8bedd86cecb3c10d1e9 (diff)
downloadqarsh-aaf5cb39094bf87ac895210c4cf7f27d4483a3b9.zip
qarsh-aaf5cb39094bf87ac895210c4cf7f27d4483a3b9.tar.gz
qarsh-aaf5cb39094bf87ac895210c4cf7f27d4483a3b9.tar.xz
sendfile() can only send about 2GB, but you can keep calling it until
everything is sent.
-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: