summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog10
-rw-r--r--NEWS10
-rw-r--r--test/ruby/test_thread.rb11
-rw-r--r--thread.c10
4 files changed, 30 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog
index 1f00486c4d..ac113ecee3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
diff --git a/NEWS b/NEWS
index 2448264ad9..f0c38d48eb 100644
--- a/NEWS
+++ b/NEWS
@@ -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
diff --git a/thread.c b/thread.c
index a0a3472b26..473713f862 100644
--- a/thread.c
+++ b/thread.c
@@ -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);