win: properly return UV_EBADF when _close() fails
Previously, libuv didn't return the correct error code when attempting to close an invalid file descriptor with `uv_fs_close()`. PR-URL: https://github.com/libuv/libuv/pull/613 Reviewed-by: Bert Belder <bertbelder@gmail.com>
This commit is contained in:
parent
dfdecf0006
commit
77eda8d90b
10
src/win/fs.c
10
src/win/fs.c
@ -533,7 +533,15 @@ void fs__close(uv_fs_t* req) {
|
|||||||
else
|
else
|
||||||
result = 0;
|
result = 0;
|
||||||
|
|
||||||
SET_REQ_RESULT(req, result);
|
/* _close doesn't set _doserrno on failure, but it does always set errno
|
||||||
|
* to EBADF on failure.
|
||||||
|
*/
|
||||||
|
if (result == -1) {
|
||||||
|
assert(errno == EBADF);
|
||||||
|
SET_REQ_UV_ERROR(req, UV_EBADF, ERROR_INVALID_HANDLE);
|
||||||
|
} else {
|
||||||
|
req->result = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user