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:
Nikolai Vavilov 2015-11-11 13:18:31 +02:00 committed by Bert Belder
parent dfdecf0006
commit 77eda8d90b

View File

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