[前][次][番号順一覧][スレッド一覧]

ruby-changes:10359

From: usa <ko1@a...>
Date: Fri, 30 Jan 2009 18:09:16 +0900 (JST)
Subject: [ruby-changes:10359] Ruby:r21903 (trunk): * win32/win32.c (rb_w32_write): limit write size to 32KB if the file

usa	2009-01-30 18:08:19 +0900 (Fri, 30 Jan 2009)

  New Revision: 21903

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=21903

  Log:
    * win32/win32.c (rb_w32_write): limit write size to 32KB if the file
      seems to be console.  [ruby-core:21613]

  Modified files:
    trunk/ChangeLog
    trunk/win32/win32.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 21902)
+++ ChangeLog	(revision 21903)
@@ -1,3 +1,8 @@
+Fri Jan 30 18:04:23 2009  NAKAMURA Usaku  <usa@r...>
+
+	* win32/win32.c (rb_w32_write): limit write size to 32KB if the file
+	  seems to be console.  [ruby-core:21613]
+
 Fri Jan 30 16:12:32 2009  TAKAO Kouji  <kouji@t...>
 
 	* ext/curses/curses.c (Init_curses): Curses#crmode and
@@ -11,7 +16,7 @@
 
 Fri Jan 30 14:11:48 2009  NAKAMURA Usaku  <usa@r...>
 
-	* enc/depend: extract comile rules to each target for VC++.
+	* enc/depend: extract compile rules to each target for nmake.
 
 Fri Jan 30 12:59:49 2009  Nobuyoshi Nakada  <nobu@r...>
 
Index: win32/win32.c
===================================================================
--- win32/win32.c	(revision 21902)
+++ win32/win32.c	(revision 21903)
@@ -4485,6 +4485,8 @@
     DWORD written;
     DWORD wait;
     DWORD err;
+    size_t len;
+    size_t ret;
     OVERLAPPED ol, *pol = NULL;
 
     if (is_socket(sock))
@@ -4506,6 +4508,12 @@
 	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));
@@ -4534,7 +4542,7 @@
 	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)
@@ -4582,9 +4590,16 @@
 	}
     }
 
+    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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]