copyup: minor fixes for sendfile()

This commit is contained in:
Stephane Thiell 2019-05-02 11:57:50 -07:00
parent cdd706782f
commit a558c9ab3c

3
main.c
View File

@ -2093,13 +2093,14 @@ copyup (struct ovl_data *lo, struct ovl_node *node)
while (copied < st.st_size) while (copied < st.st_size)
{ {
off_t tocopy = st.st_size - copied; off_t tocopy = st.st_size - copied;
ssize_t n = sendfile (dfd, sfd, NULL, tocopy > SIZE_MAX ? SIZE_MAX : (size_t) tocopy); ssize_t n = TEMP_FAILURE_RETRY (sendfile (dfd, sfd, NULL, tocopy > SIZE_MAX ? SIZE_MAX : (size_t) tocopy));
if (n < 0) if (n < 0)
{ {
/* On failure, fallback to the read/write loop. */ /* On failure, fallback to the read/write loop. */
ret = copy_fd_to_fd (sfd, dfd, buf, buf_size); ret = copy_fd_to_fd (sfd, dfd, buf, buf_size);
if (ret < 0) if (ret < 0)
goto exit; goto exit;
break;
} }
copied += n; copied += n;
} }