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.
This commit is contained in:
Saúl Ibarra Corretgé 2012-12-27 23:15:40 +01:00 committed by Ben Noordhuis
parent 69ab328d9f
commit 9614d51135

View File

@ -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);
}