diff options
author | Nikolai Vavilov <vvnicholas@gmail.com> | 2015-11-11 13:18:31 +0200 |
---|---|---|
committer | Bert Belder <bertbelder@gmail.com> | 2015-11-11 22:33:21 +0100 |
commit | 77eda8d90b51c8a654f97fd8d2c32ccc8280191a (patch) | |
tree | 4c5c78efa3f9978bb7a37ac0b2525a5573b10adb | |
parent | dfdecf000622ea4dc9eec24be8f0cae99c0469cd (diff) | |
download | libuv-77eda8d90b51c8a654f97fd8d2c32ccc8280191a.tar.gz libuv-77eda8d90b51c8a654f97fd8d2c32ccc8280191a.zip |
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>
-rw-r--r-- | src/win/fs.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/win/fs.c b/src/win/fs.c index 4a175731..fe56dba6 100644 --- a/src/win/fs.c +++ b/src/win/fs.c @@ -533,7 +533,15 @@ void fs__close(uv_fs_t* req) { else 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; + } } |