Skip to content

Commit

Permalink
Merge pull request #14 from libuv/v1.x
Browse files Browse the repository at this point in the history
unix: refactor uv__fs_copyfile() logic
  • Loading branch information
sthagen committed Oct 31, 2019
2 parents 0ed4ca1 + 780c08a commit 1d7be33
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/unix/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -999,6 +999,7 @@ static ssize_t uv__fs_copyfile(uv_fs_t* req) {
int err;
size_t bytes_to_send;
int64_t in_offset;
ssize_t bytes_written;

dstfd = -1;
err = 0;
Expand Down Expand Up @@ -1076,18 +1077,17 @@ static ssize_t uv__fs_copyfile(uv_fs_t* req) {
bytes_to_send = src_statsbuf.st_size;
in_offset = 0;
while (bytes_to_send != 0) {
err = uv_fs_sendfile(NULL,
&fs_req,
dstfd,
srcfd,
in_offset,
bytes_to_send,
NULL);
uv_fs_sendfile(NULL, &fs_req, dstfd, srcfd, in_offset, bytes_to_send, NULL);
bytes_written = fs_req.result;
uv_fs_req_cleanup(&fs_req);
if (err < 0)

if (bytes_written < 0) {
err = bytes_written;
break;
bytes_to_send -= fs_req.result;
in_offset += fs_req.result;
}

bytes_to_send -= bytes_written;
in_offset += bytes_written;
}

out:
Expand Down

0 comments on commit 1d7be33

Please sign in to comment.