diff options
Diffstat (limited to 'io.c')
-rw-r--r-- | io.c | 21 |
1 files changed, 12 insertions, 9 deletions
@@ -1187,6 +1187,15 @@ rb_io_addstr(VALUE io, VALUE str) return io; } +#ifdef HAVE_FSYNC +static VALUE nogvl_fsync(void *ptr) +{ + rb_io_t *fptr = ptr; + + return (VALUE)fsync(fptr->fd); +} +#endif + /* * call-seq: * ios.flush -> ios @@ -1220,7 +1229,7 @@ rb_io_flush(VALUE io) rb_sys_fail(0); #ifdef _WIN32 if (GetFileType((HANDLE)rb_w32_get_osfhandle(fptr->fd)) == FILE_TYPE_DISK) { - fsync(fptr->fd); + rb_thread_io_blocking_region(nogvl_fsync, fptr, fptr->fd); } #endif } @@ -1332,6 +1341,8 @@ rb_io_set_pos(VALUE io, VALUE offset) static void clear_readconv(rb_io_t *fptr); +#ifdef HAVE_FSYNC + /* * call-seq: * ios.rewind -> 0 @@ -1508,14 +1519,6 @@ rb_io_set_sync(VALUE io, VALUE sync) return 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 |