From aaf5cb39094bf87ac895210c4cf7f27d4483a3b9 Mon Sep 17 00:00:00 2001 From: Nate Straz Date: Thu, 16 Nov 2006 04:56:46 +0000 Subject: sendfile() can only send about 2GB, but you can keep calling it until everything is sent. --- qacp.c | 6 ++++-- 1 file 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: -- cgit