Skip to content

Commit 16b551f

Browse files
committed
merge revision(s) 50637: [Backport ruby#11172]
* win32/win32.c (setup_overlapped): seek to the file end only when writing (mode:a), not reading (mode:a+, read). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@50806 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent 4def227 commit 16b551f

3 files changed

Lines changed: 14 additions & 5 deletions

File tree

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
Tue Jun 9 16:24:25 2015 NARUSE, Yui <naruse@ruby-lang.org>
2+
3+
* win32/win32.c (setup_overlapped): seek to the file end only when
4+
writing (mode:a), not reading (mode:a+, read).
5+
16
Tue Jun 9 16:15:31 2015 Aaron Patterson <tenderlove@ruby-lang.org>
27

38
* load.c (loaded_feature_path): stop returning false negatives for

version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#define RUBY_VERSION "2.1.7"
22
#define RUBY_RELEASE_DATE "2015-06-09"
3-
#define RUBY_PATCHLEVEL 363
3+
#define RUBY_PATCHLEVEL 364
44

55
#define RUBY_RELEASE_YEAR 2015
66
#define RUBY_RELEASE_MONTH 6

win32/win32.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6274,12 +6274,16 @@ rb_w32_close(int fd)
62746274
}
62756275

62766276
static int
6277-
setup_overlapped(OVERLAPPED *ol, int fd)
6277+
setup_overlapped(OVERLAPPED *ol, int fd, int iswrite)
62786278
{
62796279
memset(ol, 0, sizeof(*ol));
62806280
if (!(_osfile(fd) & (FDEV | FPIPE))) {
62816281
LONG high = 0;
6282-
DWORD method = _osfile(fd) & FAPPEND ? FILE_END : FILE_CURRENT;
6282+
/* On mode:a, it can write only FILE_END.
6283+
* On mode:a+, though it can write only FILE_END,
6284+
* it can read from everywhere.
6285+
*/
6286+
DWORD method = ((_osfile(fd) & FAPPEND) && iswrite) ? FILE_END : FILE_CURRENT;
62836287
DWORD low = SetFilePointer((HANDLE)_osfhnd(fd), 0, &high, method);
62846288
#ifndef INVALID_SET_FILE_POINTER
62856289
#define INVALID_SET_FILE_POINTER ((DWORD)-1)
@@ -6376,7 +6380,7 @@ rb_w32_read(int fd, void *buf, size_t size)
63766380

63776381
/* if have cancel_io, use Overlapped I/O */
63786382
if (cancel_io) {
6379-
if (setup_overlapped(&ol, fd)) {
6383+
if (setup_overlapped(&ol, fd, FALSE)) {
63806384
MTHREAD_ONLY(LeaveCriticalSection(&_pioinfo(fd)->lock));
63816385
return -1;
63826386
}
@@ -6494,7 +6498,7 @@ rb_w32_write(int fd, const void *buf, size_t size)
64946498

64956499
/* if have cancel_io, use Overlapped I/O */
64966500
if (cancel_io) {
6497-
if (setup_overlapped(&ol, fd)) {
6501+
if (setup_overlapped(&ol, fd, TRUE)) {
64986502
MTHREAD_ONLY(LeaveCriticalSection(&_pioinfo(fd)->lock));
64996503
return -1;
65006504
}

0 commit comments

Comments
 (0)