Skip to content
Browse files

unix: reset errno when using sendfile emulation

A common way to check if a uv_fs_t request failed is to check that
req->errorno != 0.

With uv_fs_sendfile(), when the sendfile() syscall fails, req->errorno is set
to (for example) ENOTSOCK, even when the emulation code path succeeds.

Zero errno before the call to uv__fs_sendfile_emul() to prevent that from
happening.
  • Loading branch information...
1 parent 69ab328 commit 9614d5113526ba82bc8522b0b1c9a119e45932d3 @saghul saghul committed with bnoordhuis Dec 27, 2012
Showing with 2 additions and 0 deletions.
  1. +2 −0 src/unix/fs.c
View
2 src/unix/fs.c
@@ -381,6 +381,7 @@ static ssize_t uv__fs_sendfile(uv_fs_t* req) {
errno == EIO ||
errno == ENOTSOCK ||
errno == EXDEV) {
+ errno = 0;
return uv__fs_sendfile_emul(req);
}
@@ -412,6 +413,7 @@ static ssize_t uv__fs_sendfile(uv_fs_t* req) {
errno == EIO ||
errno == ENOTSOCK ||
errno == EXDEV) {
+ errno = 0;
return uv__fs_sendfile_emul(req);
}

0 comments on commit 9614d51

Please sign in to comment.
Something went wrong with that request. Please try again.