summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-11-07 11:08:39 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-11-07 11:08:39 +0000
commit66595f389473a4040e318fdfcc4b5d81cf8c2698 (patch)
tree1ba9db0cf78281eed3dcc2ca2af1f28d32e27dd1
parent987c03a387fd0cb9cc4880bfffee51e5d18209e8 (diff)
* io.c (io_fflush): remove fsync().
* io.c (rb_io_flush, rb_io_rewind): fsync() here. these changes reduces fsync() calls to improve performance. first reported at [ruby-list:48515] by ak7 at mail.goo.ne.jp . [Bug #5585] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog10
-rw-r--r--io.c15
2 files changed, 20 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 43332d48f2..da93ede475 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+Mon Nov 7 20:05:16 2011 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * io.c (io_fflush): remove fsync().
+
+ * io.c (rb_io_flush, rb_io_rewind): fsync() here.
+
+ these changes reduces fsync() calls to improve performance.
+ first reported at [ruby-list:48515] by ak7 at mail.goo.ne.jp .
+ [Bug #5585]
+
Mon Nov 7 19:43:10 2011 Tanaka Akira <akr@fsij.org>
* io.c (rb_close_before_exec): use F_MAXFD if available.
diff --git a/io.c b/io.c
index 307611f7a2..a191999942 100644
--- a/io.c
+++ b/io.c
@@ -837,11 +837,6 @@ io_fflush(rb_io_t *fptr)
return -1;
rb_io_check_closed(fptr);
}
-#ifdef _WIN32
- if (GetFileType((HANDLE)rb_w32_get_osfhandle(fptr->fd)) == FILE_TYPE_DISK) {
- fsync(fptr->fd);
- }
-#endif
return 0;
}
@@ -1223,6 +1218,11 @@ rb_io_flush(VALUE io)
if (fptr->mode & FMODE_WRITABLE) {
if (io_fflush(fptr) < 0)
rb_sys_fail(0);
+#ifdef _WIN32
+ if (GetFileType((HANDLE)rb_w32_get_osfhandle(fptr->fd)) == FILE_TYPE_DISK) {
+ fsync(fptr->fd);
+ }
+#endif
}
if (fptr->mode & FMODE_READABLE) {
io_unread(fptr);
@@ -1355,6 +1355,11 @@ rb_io_rewind(VALUE io)
GetOpenFile(io, fptr);
if (io_seek(fptr, 0L, 0) < 0 && errno) rb_sys_fail_path(fptr->pathv);
+#ifdef _WIN32
+ if (GetFileType((HANDLE)rb_w32_get_osfhandle(fptr->fd)) == FILE_TYPE_DISK) {
+ fsync(fptr->fd);
+ }
+#endif
if (io == ARGF.current_file) {
ARGF.lineno -= fptr->lineno;
}