summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-06-03 10:59:37 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-06-03 10:59:37 +0000
commit19c78f9b9bb86db1eb176181e4f444eaa781f348 (patch)
tree14bb53feaf84d76df7df9d4926c8720d7a37f1b8
parent3862d95f0e805bc0cb56926b86c4f19f25c4bdc7 (diff)
* io.c (io_fflush): windows -- call fsync() only when the FD is tied to
file, because if the FD is pipe, it blocks. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31909 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--io.c6
2 files changed, 10 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 58f90576fe..1c166c1106 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Fri Jun 3 19:58:14 2011 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * 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@ruby-lang.org>
* lib/net/http.rb (URI::HTTP#request_uri): return nil when the uri
diff --git a/io.c b/io.c
index f9fc3724f3..12002be927 100644
--- a/io.c
+++ b/io.c
@@ -683,7 +683,9 @@ io_fflush(rb_io_t *fptr)
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 @@ rb_io_fsync(VALUE io)
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