mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
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@yhbt.net> at [ruby-core:57943]. [Bug #9036] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@47545 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
23abce4bff
commit
027748a314
3 changed files with 20 additions and 7 deletions
|
@ -1,3 +1,12 @@
|
|||
Fri Sep 12 11:15:04 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* 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@yhbt.net> at [ruby-core:57943].
|
||||
[Bug #9036]
|
||||
|
||||
Wed Sep 10 12:34:34 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* io.c (io_close): ignore only "closed stream" IOError and
|
||||
|
|
12
io.c
12
io.c
|
@ -6628,10 +6628,14 @@ rb_io_reopen(int argc, VALUE *argv, VALUE file)
|
|||
}
|
||||
}
|
||||
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;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
#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"
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue