From fca18c33ac94cd3893e803bf6101d0c9b2823e1a Mon Sep 17 00:00:00 2001 From: Brandon Philips Date: Thu, 23 Feb 2012 14:23:02 -0800 Subject: [PATCH] win: fs: handle EOF in read in luvit after upgrade libuv from 243cfc to d3efef readSync started failing. It seems that the code cleanup stopped handling EOF Trivially reproduced with this local fs = require('fs') print(fs.readFileSync('foo.luvit')) --- src/win/fs.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/win/fs.c b/src/win/fs.c index 94da2919..9c112b80 100644 --- a/src/win/fs.c +++ b/src/win/fs.c @@ -294,6 +294,7 @@ void fs__read(uv_fs_t* req, uv_file file, void *buf, size_t length, OVERLAPPED overlapped, *overlapped_ptr; LARGE_INTEGER offset_; DWORD bytes; + DWORD error; VERIFY_UV_FILE(file, req); @@ -323,7 +324,12 @@ void fs__read(uv_fs_t* req, uv_file file, void *buf, size_t length, if (ReadFile(handle, buf, length, &bytes, overlapped_ptr)) { SET_REQ_RESULT(req, bytes); } else { - SET_REQ_WIN32_ERROR(req, GetLastError()); + error = GetLastError(); + if (error == ERROR_HANDLE_EOF) { + SET_REQ_RESULT(req, bytes); + } else { + SET_REQ_WIN32_ERROR(req, error); + } } }