diff options
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | NEWS | 10 | ||||
-rw-r--r-- | test/ruby/test_thread.rb | 11 | ||||
-rw-r--r-- | thread.c | 10 |
4 files changed, 30 insertions, 11 deletions
@@ -1,3 +1,13 @@ +Wed Nov 28 12:54:59 2012 KOSAKI Motohiro <kosaki.motohiro@gmail.com> + + * thread.c (thread_join): A trap handler check was moved from + thread_join_m because Thread#value should be raised an exception + too. + * thread.c (thread_join_m): remove trap handler check. + * test/ruby/test_thread.rb (test_thread_join_in_trap): add test + for thread#value. + * NEWS: documentation fix for the above. + Wed Nov 28 11:07:00 2012 Zachary Scott <zachary@zacharyscott.net> * ext/fiddle/closure.c: Documentation for Fiddle @@ -164,10 +164,10 @@ with all sufficient information, see the ChangeLog file. * added Thread#backtrace_locations which returns similar information of Kernel#caller_locations. * incompatible changes: - * Thread#join is no longer allowed to be used from trap handler and - raises a ThreadError in such case. - * Thread#join now raises a ThreadError if target thread is the current - or main thread. + * Thread#join and Thread#value is no longer allowed to be used from trap + handler and raises a ThreadError in such case. + * Thread#join and Thread#value now raises a ThreadError if target thread + is the current or main thread. * Time * change return value: @@ -376,7 +376,7 @@ with all sufficient information, see the ChangeLog file. * OpenStruct new methods can conflict with custom attributes named "each_pair", "eql?", "hash" or "to_h". - * Thread#join + * Thread#join, Thread#value See above. diff --git a/test/ruby/test_thread.rb b/test/ruby/test_thread.rb index 13d1a3ff65..30e886447e 100644 --- a/test/ruby/test_thread.rb +++ b/test/ruby/test_thread.rb @@ -874,6 +874,17 @@ class TestThreadGroup < Test::Unit::TestCase t.join } + + assert_raise(ThreadError) { + t = Thread.new{ sleep 0.2; Process.kill(:INT, $$) } + + Signal.trap :INT do + t.value + end + + t.value + } + end def test_thread_join_current @@ -740,6 +740,10 @@ thread_join(rb_thread_t *target_th, double delay) if (GET_VM()->main_thread == target_th) { rb_raise(rb_eThreadError, "Target thread must not be main thread"); } + /* When running trap handler */ + if (th->interrupt_mask & TRAP_INTERRUPT_MASK) { + rb_raise(rb_eThreadError, "can't be called from trap context"); + } arg.target = target_th; arg.waiting = th; @@ -822,15 +826,9 @@ static VALUE thread_join_m(int argc, VALUE *argv, VALUE self) { rb_thread_t *target_th; - rb_thread_t *cur_th = GET_THREAD(); double delay = DELAY_INFTY; VALUE limit; - /* When running trap handler */ - if (cur_th->interrupt_mask & TRAP_INTERRUPT_MASK) { - rb_raise(rb_eThreadError, "can't be called from trap context"); - } - GetThreadPtr(self, target_th); rb_scan_args(argc, argv, "01", &limit); |