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

ruby-changes:9444

From: usa <ko1@a...>
Date: Thu, 25 Dec 2008 13:29:46 +0900 (JST)
Subject: [ruby-changes:9444] Ruby:r20982 (trunk): * io.c (rb_io_flush): fsync() after buffer is flushed on win32.

usa	2008-12-25 13:29:30 +0900 (Thu, 25 Dec 2008)

  New Revision: 20982

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

  Log:
    * io.c (rb_io_flush): fsync() after buffer is flushed on win32.
      [ruby-core:20043]

  Modified files:
    trunk/ChangeLog
    trunk/io.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 20981)
+++ ChangeLog	(revision 20982)
@@ -1,3 +1,8 @@
+Thu Dec 25 13:28:20 2008  NAKAMURA Usaku  <usa@r...>
+
+	* io.c (rb_io_flush): fsync() after buffer is flushed on win32.
+	  [ruby-core:20043]
+
 Thu Dec 25 13:13:00 2008  Koichi Sasada  <ko1@a...>
 
 	* vm_insnhelper.c (vm_method_search): return rb_cObject if there is no
Index: io.c
===================================================================
--- io.c	(revision 20981)
+++ io.c	(revision 20982)
@@ -983,6 +983,9 @@
 
     if (fptr->mode & FMODE_WRITABLE) {
         io_fflush(fptr);
+#ifdef _WIN32
+	fsync(fptr->fd);
+#endif
     }
     if (fptr->mode & FMODE_READABLE) {
         io_unread(fptr);
@@ -4416,7 +4419,9 @@
         }
     }
 }
+#endif
 
+#if defined(HAVE_FORK) || defined(_WIN32)
 void
 rb_close_before_exec(int lowfd, int maxhint, VALUE noclose_fds)
 {
@@ -4433,12 +4438,16 @@
 	if (ret != -1 && !(ret & FD_CLOEXEC)) {
             fcntl(fd, F_SETFD, ret|FD_CLOEXEC);
         }
+#elif defined(_WIN32)
+	rb_w32_fd_noinherit(fd);
 #else
 	close(fd);
 #endif
     }
 }
+#endif
 
+#ifdef HAVE_FORK
 static int
 popen_exec(void *pp, char *errmsg, size_t errmsg_len)
 {
@@ -5922,13 +5931,15 @@
 
     fd = NUM2INT(fnum);
     UPDATE_MAXFD(fd);
+#if defined(HAVE_FCNTL) && defined(F_GETFL)
     if (NIL_P(vmode)) {
-#if defined(HAVE_FCNTL) && defined(F_GETFL)
         oflags = fcntl(fd, F_GETFL);
         if (oflags == -1) rb_sys_fail(0);
         fmode = rb_io_oflags_fmode(oflags);
+    }
+#elif defined(_WIN32)
+    if (rb_w32_is_valid_fd(fd)) rb_sys_fail(0);
 #endif
-    }
     MakeOpenFile(io, fp);
     fp->fd = fd;
     fp->mode = fmode;

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

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