summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authorkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-11-24 02:57:57 +0000
committerkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-11-24 02:57:57 +0000
commitd7166624bf70c2fe9f0b067065b9fd490de16d20 (patch)
tree11998d2ba33a3afb2cd28f1f08ba69d518d29866 /io.c
parent452b74c10682280912d14254795d2e76894fbdc9 (diff)
Merge branch 'fsync-nogvl' into trunk
Conflicts: ChangeLog git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33826 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r--io.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/io.c b/io.c
index 0410e6339f..31b07f9c0a 100644
--- a/io.c
+++ b/io.c
@@ -1509,6 +1509,13 @@ rb_io_set_sync(VALUE io, VALUE sync)
}
#ifdef HAVE_FSYNC
+static VALUE nogvl_fsync(void *ptr)
+{
+ rb_io_t *fptr = ptr;
+
+ return (VALUE)fsync(fptr->fd);
+}
+
/*
* call-seq:
* ios.fsync -> 0 or nil
@@ -1534,7 +1541,7 @@ 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)
+ if ((int)rb_thread_io_blocking_region(nogvl_fsync, fptr, fptr->fd) < 0)
rb_sys_fail_path(fptr->pathv);
#endif
return INT2FIX(0);
@@ -1544,6 +1551,13 @@ rb_io_fsync(VALUE io)
#endif
#ifdef HAVE_FDATASYNC
+static VALUE nogvl_fdatasync(void *ptr)
+{
+ rb_io_t *fptr = ptr;
+
+ return (VALUE)fdatasync(fptr->fd);
+}
+
/*
* call-seq:
* ios.fdatasync -> 0 or nil
@@ -1566,7 +1580,7 @@ rb_io_fdatasync(VALUE io)
if (io_fflush(fptr) < 0)
rb_sys_fail(0);
- if (fdatasync(fptr->fd) == 0)
+ if ((int)rb_thread_io_blocking_region(nogvl_fdatasync, fptr, fptr->fd) == 0)
return INT2FIX(0);
/* fall back */