summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--version.h2
-rw-r--r--win32/win32.c19
3 files changed, 23 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 4b25a82bae..e9837eea6f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Fri Jan 30 18:04:23 2009 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * win32/win32.c (rb_w32_write): limit write size to 32KB if the file
+ seems to be console. [ruby-core:21613]
+
Sat Oct 3 22:14:18 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* parse.y (bv_decls, bvar): fix for block variables.
diff --git a/version.h b/version.h
index 225831fdf9..733f5ef189 100644
--- a/version.h
+++ b/version.h
@@ -1,5 +1,5 @@
#define RUBY_VERSION "1.9.1"
-#define RUBY_PATCHLEVEL 360
+#define RUBY_PATCHLEVEL 361
#define RUBY_VERSION_MAJOR 1
#define RUBY_VERSION_MINOR 9
#define RUBY_VERSION_TEENY 1
diff --git a/win32/win32.c b/win32/win32.c
index b461a78b03..e10fa89661 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -4483,6 +4483,8 @@ rb_w32_write(int fd, const void *buf, size_t size)
DWORD written;
DWORD wait;
DWORD err;
+ size_t len;
+ size_t ret;
OVERLAPPED ol, *pol = NULL;
if (is_socket(sock))
@@ -4504,6 +4506,12 @@ rb_w32_write(int fd, const void *buf, size_t size)
return 0;
}
+ ret = 0;
+ retry:
+ /* get rid of console writing bug */
+ len = (_osfile(fd) & FDEV) ? min(32 * 1024, size) : size;
+ size -= len;
+
/* if have cancel_io, use Overlapped I/O */
if (cancel_io) {
memset(&ol, 0, sizeof(ol));
@@ -4532,7 +4540,7 @@ rb_w32_write(int fd, const void *buf, size_t size)
pol = &ol;
}
- if (!WriteFile((HANDLE)_osfhnd(fd), buf, size, &written, pol)) {
+ if (!WriteFile((HANDLE)_osfhnd(fd), buf, len, &written, pol)) {
err = GetLastError();
if (err != ERROR_IO_PENDING) {
if (err == ERROR_ACCESS_DENIED)
@@ -4580,9 +4588,16 @@ rb_w32_write(int fd, const void *buf, size_t size)
}
}
+ ret += written;
+ if (written == len) {
+ (const char *)buf += len;
+ if (size > 0)
+ goto retry;
+ }
+
MTHREAD_ONLY(LeaveCriticalSection(&_pioinfo(fd)->lock));
- return written;
+ return ret;
}
static int