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

ruby-changes:19862

From: usa <ko1@a...>
Date: Fri, 3 Jun 2011 20:03:44 +0900 (JST)
Subject: [ruby-changes:19862] usa:r31909 (trunk): * io.c (io_fflush): windows -- call fsync() only when the FD is tied to

usa	2011-06-03 19:59:37 +0900 (Fri, 03 Jun 2011)

  New Revision: 31909

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

  Log:
    * io.c (io_fflush): windows -- call fsync() only when the FD is tied to
      file, because if the FD is pipe, it blocks.

  Modified files:
    trunk/ChangeLog
    trunk/io.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 31908)
+++ ChangeLog	(revision 31909)
@@ -1,3 +1,8 @@
+Fri Jun  3 19:58:14 2011  NAKAMURA Usaku  <usa@r...>
+
+	* io.c (io_fflush): windows -- call fsync() only when the FD is tied to
+	  file, because if the FD is pipe, it blocks.
+
 Fri Jun  3 09:27:31 2011  NARUSE, Yui  <naruse@r...>
 
 	* lib/net/http.rb (URI::HTTP#request_uri): return nil when the uri
Index: io.c
===================================================================
--- io.c	(revision 31908)
+++ io.c	(revision 31909)
@@ -683,7 +683,9 @@
         rb_io_check_closed(fptr);
     }
 #ifdef _WIN32
-    fsync(fptr->fd);
+    if (GetFileType((HANDLE)rb_w32_get_osfhandle(fptr->fd)) == FILE_TYPE_DISK) {
+	fsync(fptr->fd);
+    }
 #endif
     return 0;
 }
@@ -1368,8 +1370,10 @@
 
     if (io_fflush(fptr) < 0)
         rb_sys_fail(0);
+#ifndef _WIN32	/* already called in io_fflush() */
     if (fsync(fptr->fd) < 0)
 	rb_sys_fail_path(fptr->pathv);
+#endif
     return INT2FIX(0);
 }
 #else

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

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