Skip to content
This repository has been archived by the owner on May 4, 2018. It is now read-only.

Commit

Permalink
win: fs: handle EOF in read
Browse files Browse the repository at this point in the history
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'))
  • Loading branch information
philips authored and piscisaureus committed Feb 23, 2012
1 parent c0e7044 commit fca18c3
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/win/fs.c
Expand Up @@ -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);

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

Expand Down

0 comments on commit fca18c3

Please sign in to comment.