ruby-changes:35463
From: usa <ko1@a...>
Date: Fri, 12 Sep 2014 11:20:12 +0900 (JST)
Subject: [ruby-changes:35463] usa:r47545 (ruby_2_0_0): merge revision(s) 43373: [Backport #9036]
usa 2014-09-12 11:20:06 +0900 (Fri, 12 Sep 2014) New Revision: 47545 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=47545 Log: merge revision(s) 43373: [Backport #9036] * io.c (rb_io_reopen): create a new, temporary FD via rb_sysopen and call rb_cloexec_dup2 on it to atomically replace the file fptr->fd points to. This leaves no possible window where fptr->fd is invalid to userspace (even for any threads running w/o GVL). based on the patch by Eric Wong <normalperson@y...> at [ruby-core:57943]. [Bug #9036] Modified directories: branches/ruby_2_0_0/ Modified files: branches/ruby_2_0_0/ChangeLog branches/ruby_2_0_0/io.c branches/ruby_2_0_0/version.h Index: ruby_2_0_0/ChangeLog =================================================================== --- ruby_2_0_0/ChangeLog (revision 47544) +++ ruby_2_0_0/ChangeLog (revision 47545) @@ -1,3 +1,12 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ChangeLog#L1 +Fri Sep 12 11:15:04 2014 Nobuyoshi Nakada <nobu@r...> + + * io.c (rb_io_reopen): create a new, temporary FD via rb_sysopen and + call rb_cloexec_dup2 on it to atomically replace the file fptr->fd + points to. This leaves no possible window where fptr->fd is invalid + to userspace (even for any threads running w/o GVL). based on the + patch by Eric Wong <normalperson@y...> at [ruby-core:57943]. + [Bug #9036] + Wed Sep 10 12:34:34 2014 Nobuyoshi Nakada <nobu@r...> * io.c (io_close): ignore only "closed stream" IOError and Index: ruby_2_0_0/io.c =================================================================== --- ruby_2_0_0/io.c (revision 47544) +++ ruby_2_0_0/io.c (revision 47545) @@ -6628,10 +6628,14 @@ rb_io_reopen(int argc, VALUE *argv, VALU https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/io.c#L6628 } } else { - if (close(fptr->fd) < 0) - rb_sys_fail_path(fptr->pathv); - fptr->fd = -1; - fptr->fd = rb_sysopen(fptr->pathv, oflags, 0666); + int tmpfd = rb_sysopen(fptr->pathv, oflags, 0666); + int err = 0; + if (rb_cloexec_dup2(tmpfd, fptr->fd) < 0) + err = errno; + (void)close(tmpfd); + if (err) { + rb_sys_fail_path(fptr->pathv); + } } return file; Index: ruby_2_0_0/version.h =================================================================== --- ruby_2_0_0/version.h (revision 47544) +++ ruby_2_0_0/version.h (revision 47545) @@ -1,10 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/version.h#L1 #define RUBY_VERSION "2.0.0" -#define RUBY_RELEASE_DATE "2014-09-10" -#define RUBY_PATCHLEVEL 566 +#define RUBY_RELEASE_DATE "2014-09-12" +#define RUBY_PATCHLEVEL 567 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 9 -#define RUBY_RELEASE_DAY 10 +#define RUBY_RELEASE_DAY 12 #include "ruby/version.h" Property changes on: ruby_2_0_0 ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r43373 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/