ruby-changes:47114
From: usa <ko1@a...>
Date: Fri, 30 Jun 2017 21:09:15 +0900 (JST)
Subject: [ruby-changes:47114] usa:r59229 (ruby_2_3): merge revision(s) 59030, 59031: [Backport #13638]
usa 2017-06-30 21:09:10 +0900 (Fri, 30 Jun 2017) New Revision: 59229 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=59229 Log: merge revision(s) 59030,59031: [Backport #13638] thread.c: avoid busy looping on rb_thread_fd_close We no longer use it this function, but extensions do, and we need to ensure it continues to work for them. * thread.c (rb_thread_fd_close): schedule other threads in loop * ext/-test-/thread_fd_close/thread_fd_close.c: new file * ext/-test-/thread_fd_close/depend: ditto * ext/-test-/thread_fd_close/extconf.rb: ditto * test/-ext-/thread_fd_close/test_thread_fd_close.rb: new test * properties. Added directories: branches/ruby_2_3/ext/-test-/thread_fd_close/ branches/ruby_2_3/test/-ext-/thread_fd_close/ Modified directories: branches/ruby_2_3/ Modified files: branches/ruby_2_3/ChangeLog branches/ruby_2_3/eval.c branches/ruby_2_3/ext/-test-/thread_fd_close/depend branches/ruby_2_3/ext/-test-/thread_fd_close/extconf.rb branches/ruby_2_3/ext/-test-/thread_fd_close/thread_fd_close.c branches/ruby_2_3/test/-ext-/thread_fd_close/test_thread_fd_close.rb branches/ruby_2_3/thread.c branches/ruby_2_3/version.h Index: ruby_2_3/thread.c =================================================================== --- ruby_2_3/thread.c (revision 59228) +++ ruby_2_3/thread.c (revision 59229) @@ -2190,7 +2190,7 @@ rb_notify_fd_close(int fd) https://github.com/ruby/ruby/blob/trunk/ruby_2_3/thread.c#L2190 void rb_thread_fd_close(int fd) { - while (rb_notify_fd_close(fd)); + while (rb_notify_fd_close(fd)) rb_thread_schedule(); } /* Index: ruby_2_3/version.h =================================================================== --- ruby_2_3/version.h (revision 59228) +++ ruby_2_3/version.h (revision 59229) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/version.h#L1 #define RUBY_VERSION "2.3.5" #define RUBY_RELEASE_DATE "2017-06-30" -#define RUBY_PATCHLEVEL 325 +#define RUBY_PATCHLEVEL 326 #define RUBY_RELEASE_YEAR 2017 #define RUBY_RELEASE_MONTH 6 Index: ruby_2_3/ext/-test-/thread_fd_close/depend =================================================================== --- ruby_2_3/ext/-test-/thread_fd_close/depend (nonexistent) +++ ruby_2_3/ext/-test-/thread_fd_close/depend (revision 59229) @@ -0,0 +1,14 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/ext/-test-/thread_fd_close/depend#L1 +# AUTOGENERATED DEPENDENCIES START +thread_fd_close.o: $(RUBY_EXTCONF_H) +thread_fd_close.o: $(arch_hdrdir)/ruby/config.h +thread_fd_close.o: $(hdrdir)/ruby/defines.h +thread_fd_close.o: $(hdrdir)/ruby/encoding.h +thread_fd_close.o: $(hdrdir)/ruby/intern.h +thread_fd_close.o: $(hdrdir)/ruby/io.h +thread_fd_close.o: $(hdrdir)/ruby/missing.h +thread_fd_close.o: $(hdrdir)/ruby/oniguruma.h +thread_fd_close.o: $(hdrdir)/ruby/ruby.h +thread_fd_close.o: $(hdrdir)/ruby/st.h +thread_fd_close.o: $(hdrdir)/ruby/subst.h +thread_fd_close.o: thread_fd_close.c +# AUTOGENERATED DEPENDENCIES END Property changes on: ruby_2_3/ext/-test-/thread_fd_close/depend ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +LF \ No newline at end of property Index: ruby_2_3/ext/-test-/thread_fd_close/thread_fd_close.c =================================================================== --- ruby_2_3/ext/-test-/thread_fd_close/thread_fd_close.c (nonexistent) +++ ruby_2_3/ext/-test-/thread_fd_close/thread_fd_close.c (revision 59229) @@ -0,0 +1,14 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/ext/-test-/thread_fd_close/thread_fd_close.c#L1 +#include "ruby/ruby.h" + +static VALUE +thread_fd_close(VALUE ign, VALUE fd) +{ + rb_thread_fd_close(NUM2INT(fd)); + return Qnil; +} + +void +Init_thread_fd_close(void) +{ + rb_define_singleton_method(rb_cIO, "thread_fd_close", thread_fd_close, 1); +} Property changes on: ruby_2_3/ext/-test-/thread_fd_close/thread_fd_close.c ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +LF \ No newline at end of property Index: ruby_2_3/ext/-test-/thread_fd_close/extconf.rb =================================================================== --- ruby_2_3/ext/-test-/thread_fd_close/extconf.rb (nonexistent) +++ ruby_2_3/ext/-test-/thread_fd_close/extconf.rb (revision 59229) @@ -0,0 +1,2 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/ext/-test-/thread_fd_close/extconf.rb#L1 +# frozen_string_literal: true +create_makefile('-test-/thread_fd_close') Property changes on: ruby_2_3/ext/-test-/thread_fd_close/extconf.rb ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +LF \ No newline at end of property Index: ruby_2_3/test/-ext-/thread_fd_close/test_thread_fd_close.rb =================================================================== --- ruby_2_3/test/-ext-/thread_fd_close/test_thread_fd_close.rb (nonexistent) +++ ruby_2_3/test/-ext-/thread_fd_close/test_thread_fd_close.rb (revision 59229) @@ -0,0 +1,23 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/test/-ext-/thread_fd_close/test_thread_fd_close.rb#L1 +# frozen_string_literal: true +require 'test/unit' +require '-test-/thread_fd_close' +require 'io/wait' + +class TestThreadFdClose < Test::Unit::TestCase + + def test_thread_fd_close + IO.pipe do |r, w| + th = Thread.new do + begin + r.read(4) + ensure + w.syswrite('done') + end + end + Thread.pass until th.stop? + IO.thread_fd_close(r.fileno) + assert_equal 'done', r.read(4) + assert_raise(IOError) { th.join } + end + end +end Property changes on: ruby_2_3/test/-ext-/thread_fd_close/test_thread_fd_close.rb ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +LF \ No newline at end of property Index: ruby_2_3/ChangeLog =================================================================== --- ruby_2_3/ChangeLog (revision 59228) +++ ruby_2_3/ChangeLog (revision 59229) @@ -1,3 +1,25 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/ChangeLog#L1 +Fri Jun 30 21:07:56 2017 NAKAMURA Usaku <usa@r...> + + * eval.c (exc_setup_cause): need to unfreeze(=dup) the exception before + setting cause if its frozen. + +Fri Jun 30 21:07:14 2017 Eric Wong <e@8...> + + thread.c: avoid busy looping on rb_thread_fd_close + + We no longer use it this function, but extensions do, and + we need to ensure it continues to work for them. + + * thread.c (rb_thread_fd_close): schedule other threads in loop + + * ext/-test-/thread_fd_close/thread_fd_close.c: new file + + * ext/-test-/thread_fd_close/depend: ditto + + * ext/-test-/thread_fd_close/extconf.rb: ditto + + * test/-ext-/thread_fd_close/test_thread_fd_close.rb: new test + Fri Jun 30 20:34:49 2017 Kazuhiro NISHIYAMA <zn@m...> * sample/pty/shl.rb: update sample Index: ruby_2_3/eval.c =================================================================== --- ruby_2_3/eval.c (revision 59228) +++ ruby_2_3/eval.c (revision 59229) @@ -458,6 +458,8 @@ exc_setup_cause(VALUE exc, VALUE cause) https://github.com/ruby/ruby/blob/trunk/ruby_2_3/eval.c#L458 } #endif if (!NIL_P(cause) && cause != exc) { + if (OBJ_FROZEN(exc)) + exc = rb_obj_dup(exc); rb_ivar_set(exc, id_cause, cause); } return exc; @@ -487,13 +489,13 @@ setup_exception(rb_thread_t *th, int tag https://github.com/ruby/ruby/blob/trunk/ruby_2_3/eval.c#L489 nocause = 0; } if (cause != Qundef) { - exc_setup_cause(mesg, cause); + mesg = exc_setup_cause(mesg, cause); } else if (nocause) { - exc_setup_cause(mesg, Qnil); + mesg = exc_setup_cause(mesg, Qnil); } else if (!rb_ivar_defined(mesg, id_cause)) { - exc_setup_cause(mesg, get_thread_errinfo(th)); + mesg = exc_setup_cause(mesg, get_thread_errinfo(th)); } file = rb_source_loc(&line); Index: ruby_2_3 =================================================================== --- ruby_2_3 (revision 59228) +++ ruby_2_3 (revision 59229) Property changes on: ruby_2_3 ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /trunk:r59030-59031 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/