Skip to content

Commit

Permalink
Merge branch 'fsread-fix' of https://github.com/unknownbrackets/libuv
Browse files Browse the repository at this point in the history
…into helper-lock
  • Loading branch information
unknownbrackets committed Oct 25, 2014
2 parents da0b081 + 1671ad9 commit b7da875
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
2 changes: 1 addition & 1 deletion libuv/configure.ac
Expand Up @@ -13,7 +13,7 @@
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

AC_PREREQ(2.57)
AC_INIT([libuv], [1.0.0-rc2], [https://github.com/joyent/libuv/issues])
AC_INIT([libuv], [1.0.0-rc3], [https://github.com/joyent/libuv/issues])
AC_CONFIG_MACRO_DIR([m4])
m4_include([m4/libuv-extra-automake-flags.m4])
m4_include([m4/as_case.m4])
Expand Down
4 changes: 2 additions & 2 deletions libuv/include/uv-version.h
Expand Up @@ -33,7 +33,7 @@
#define UV_VERSION_MAJOR 1
#define UV_VERSION_MINOR 0
#define UV_VERSION_PATCH 0
#define UV_VERSION_IS_RELEASE 1
#define UV_VERSION_SUFFIX "rc2"
#define UV_VERSION_IS_RELEASE 0
#define UV_VERSION_SUFFIX "rc3"

#endif /* UV_VERSION_H */
12 changes: 7 additions & 5 deletions libuv/src/win/fs.c
Expand Up @@ -558,10 +558,6 @@ void fs__read(uv_fs_t* req) {
if (offset != -1) {
memset(&overlapped, 0, sizeof overlapped);

offset_.QuadPart = offset;
overlapped.Offset = offset_.LowPart;
overlapped.OffsetHigh = offset_.HighPart;

overlapped_ptr = &overlapped;
} else {
overlapped_ptr = NULL;
Expand All @@ -571,6 +567,13 @@ void fs__read(uv_fs_t* req) {
bytes = 0;
do {
DWORD incremental_bytes;

if (offset != -1) {
offset_.QuadPart = offset + bytes;
overlapped.Offset = offset_.LowPart;
overlapped.OffsetHigh = offset_.HighPart;
}

result = ReadFile(handle,
req->bufs[index].base,
req->bufs[index].len,
Expand Down Expand Up @@ -623,7 +626,6 @@ void fs__write(uv_fs_t* req) {
do {
DWORD incremental_bytes;

/* WriteFile() does not advance overlapped as ReadFile() does. */
if (offset != -1) {
offset_.QuadPart = offset + bytes;
overlapped.Offset = offset_.LowPart;
Expand Down
12 changes: 8 additions & 4 deletions libuv/test/test-fs.c
Expand Up @@ -109,6 +109,7 @@ static uv_fs_t utime_req;
static uv_fs_t futime_req;

static char buf[32];
static char buf2[32];
static char test_buf[] = "test-buffer\n";
static char test_buf2[] = "second-buffer\n";
static uv_buf_t iov;
Expand Down Expand Up @@ -2200,12 +2201,15 @@ TEST_IMPL(fs_write_multiple_bufs) {
uv_fs_req_cleanup(&open_req1);

memset(buf, 0, sizeof(buf));
iov = uv_buf_init(buf, sizeof(buf));
r = uv_fs_read(loop, &read_req, open_req1.result, &iov, 1, -1, NULL);
memset(buf2, 0, sizeof(buf2));
/* Read the strings back to separate buffers. */
iovs[0] = uv_buf_init(buf, sizeof(test_buf));
iovs[1] = uv_buf_init(buf2, sizeof(test_buf2));
r = uv_fs_read(loop, &read_req, open_req1.result, iovs, 2, 0, NULL);
ASSERT(r >= 0);
ASSERT(read_req.result >= 0);
ASSERT(memcmp(buf, test_buf, sizeof(test_buf)) == 0);
ASSERT(strcmp(buf + sizeof(test_buf), test_buf2) == 0);
ASSERT(strcmp(buf, test_buf) == 0);
ASSERT(strcmp(buf2, test_buf2) == 0);
uv_fs_req_cleanup(&read_req);

iov = uv_buf_init(buf, sizeof(buf));
Expand Down

0 comments on commit b7da875

Please sign in to comment.