* win32/win32.c (rb_w32_read): limit read size to 16KB if the file
seems to be console. [ruby-core:28902] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27029 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
152934a300
commit
cb2f56aaf4
@ -1,3 +1,8 @@
|
|||||||
|
Wed Mar 24 14:33:56 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* win32/win32.c (rb_w32_read): limit read size to 16KB if the file
|
||||||
|
seems to be console. [ruby-core:28902]
|
||||||
|
|
||||||
Wed Mar 24 10:18:12 2010 NARUSE, Yui <naruse@ruby-lang.org>
|
Wed Mar 24 10:18:12 2010 NARUSE, Yui <naruse@ruby-lang.org>
|
||||||
|
|
||||||
* file.c (file_expand_path): set length of string before calling
|
* file.c (file_expand_path): set length of string before calling
|
||||||
|
@ -4835,6 +4835,8 @@ rb_w32_read(int fd, void *buf, size_t size)
|
|||||||
DWORD read;
|
DWORD read;
|
||||||
DWORD wait;
|
DWORD wait;
|
||||||
DWORD err;
|
DWORD err;
|
||||||
|
size_t len;
|
||||||
|
size_t ret;
|
||||||
OVERLAPPED ol, *pol = NULL;
|
OVERLAPPED ol, *pol = NULL;
|
||||||
|
|
||||||
if (is_socket(sock))
|
if (is_socket(sock))
|
||||||
@ -4856,6 +4858,12 @@ rb_w32_read(int fd, void *buf, size_t size)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret = 0;
|
||||||
|
retry:
|
||||||
|
/* get rid of console writing bug */
|
||||||
|
len = (_osfile(fd) & FDEV) ? min(16 * 1024, size) : size;
|
||||||
|
size -= len;
|
||||||
|
|
||||||
/* if have cancel_io, use Overlapped I/O */
|
/* if have cancel_io, use Overlapped I/O */
|
||||||
if (cancel_io) {
|
if (cancel_io) {
|
||||||
memset(&ol, 0, sizeof(ol));
|
memset(&ol, 0, sizeof(ol));
|
||||||
@ -4884,7 +4892,7 @@ rb_w32_read(int fd, void *buf, size_t size)
|
|||||||
pol = &ol;
|
pol = &ol;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ReadFile((HANDLE)_osfhnd(fd), buf, size, &read, pol)) {
|
if (!ReadFile((HANDLE)_osfhnd(fd), buf, len, &read, pol)) {
|
||||||
err = GetLastError();
|
err = GetLastError();
|
||||||
if (err != ERROR_IO_PENDING) {
|
if (err != ERROR_IO_PENDING) {
|
||||||
if (err == ERROR_ACCESS_DENIED)
|
if (err == ERROR_ACCESS_DENIED)
|
||||||
@ -4940,9 +4948,16 @@ rb_w32_read(int fd, void *buf, size_t size)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret += read;
|
||||||
|
if (read == len) {
|
||||||
|
buf = (char *)buf + len;
|
||||||
|
if (size > 0)
|
||||||
|
goto retry;
|
||||||
|
}
|
||||||
|
|
||||||
MTHREAD_ONLY(LeaveCriticalSection(&_pioinfo(fd)->lock));
|
MTHREAD_ONLY(LeaveCriticalSection(&_pioinfo(fd)->lock));
|
||||||
|
|
||||||
return read;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef write
|
#undef write
|
||||||
|
Loading…
x
Reference in New Issue
Block a user