diff options
-rw-r--r-- | qacp.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -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: |