merge revision(s) 56036,56041: [Backport #12713]

* 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.
	  incompatible with ruby 2.1 and earlier unintentionally introduced.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@56306 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
usa 2016-09-30 15:55:41 +00:00
parent 4af941c708
commit 6468b9bec0
3 changed files with 16 additions and 1 deletions

View file

@ -1,3 +1,10 @@
Sat Oct 1 00:55:19 2016 NAKAMURA Usaku <usa@ruby-lang.org>
* 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
incompatible with ruby 2.1 and earlier unintentionally introduced.
Sat Oct 1 00:53:28 2016 Kazuki Tsujimoto <kazuki@callcc.net> Sat Oct 1 00:53:28 2016 Kazuki Tsujimoto <kazuki@callcc.net>
* array.c (flatten): use rb_obj_class instead of rb_class_of * array.c (flatten): use rb_obj_class instead of rb_class_of

8
io.c
View file

@ -1525,6 +1525,10 @@ nogvl_fsync(void *ptr)
{ {
rb_io_t *fptr = 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); return (VALUE)fsync(fptr->fd);
} }
#endif #endif
@ -1926,6 +1930,10 @@ nogvl_fdatasync(void *ptr)
{ {
rb_io_t *fptr = 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); return (VALUE)fdatasync(fptr->fd);
} }

View file

@ -1,6 +1,6 @@
#define RUBY_VERSION "2.2.6" #define RUBY_VERSION "2.2.6"
#define RUBY_RELEASE_DATE "2016-10-01" #define RUBY_RELEASE_DATE "2016-10-01"
#define RUBY_PATCHLEVEL 375 #define RUBY_PATCHLEVEL 376
#define RUBY_RELEASE_YEAR 2016 #define RUBY_RELEASE_YEAR 2016
#define RUBY_RELEASE_MONTH 10 #define RUBY_RELEASE_MONTH 10