From 0df79477bd2cd534ad2d89bfdbf9708c64b59eed Mon Sep 17 00:00:00 2001 From: usa Date: Tue, 30 Aug 2016 05:59:17 +0000 Subject: * io.c (nogvl_fsync, nogvl_fdatasync): on Windows, just ignore if the fd is associated to non-disk device. if call fsync and/or fdatasync with such fds, it causes Errno::EBADF exception and the behavior is incomatible with ruby 2.1 and earlier unintendedly introduced. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56036 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- io.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'io.c') diff --git a/io.c b/io.c index fbd24f6046..137bc77fb1 100644 --- a/io.c +++ b/io.c @@ -1533,6 +1533,10 @@ nogvl_fsync(void *ptr) { rb_io_t *fptr = ptr; +#ifdef _WIN32 + if (GetFileType((HANDLE)rb_w32_get_osfhandle(fptr->fd)) != FILE_TYPE_DISK) + return 0; +#endif return (VALUE)fsync(fptr->fd); } #endif @@ -1935,6 +1939,10 @@ nogvl_fdatasync(void *ptr) { rb_io_t *fptr = ptr; +#ifdef _WIN32 + if (GetFileType((HANDLE)rb_w32_get_osfhandle(fptr->fd)) != FILE_TYPE_DISK) + return 0; +#endif return (VALUE)fdatasync(fptr->fd); } -- cgit v1.2.3