* thread.c (thread_join): raises ThreadError if target therad
is a main thread. * test/ruby/test_thread.rb (test_thread_join_main_thread): test for the above. * NEWS: news for the above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37884 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
8079f8a6f2
commit
b1a18cf49b
@ -1,3 +1,11 @@
|
|||||||
|
Tue Nov 27 09:29:11 2012 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
|
||||||
|
|
||||||
|
* thread.c (thread_join): raises ThreadError if target therad
|
||||||
|
is a main thread.
|
||||||
|
* test/ruby/test_thread.rb (test_thread_join_main_thread):
|
||||||
|
test for the above.
|
||||||
|
* NEWS: news for the above.
|
||||||
|
|
||||||
Tue Nov 27 09:24:47 2012 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
|
Tue Nov 27 09:24:47 2012 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
|
||||||
|
|
||||||
* thread.c (thread_join): raises ThreadError if target thread
|
* thread.c (thread_join): raises ThreadError if target thread
|
||||||
|
2
NEWS
2
NEWS
@ -160,7 +160,7 @@ with all sufficient information, see the ChangeLog file.
|
|||||||
* incompatible changes:
|
* incompatible changes:
|
||||||
* Thread#join no longer allows to be used from trap handler. Now it raises
|
* Thread#join no longer allows to be used from trap handler. Now it raises
|
||||||
ThreadError.
|
ThreadError.
|
||||||
* Thread#join raises ThreadError if target therad is a current thread.
|
* Thread#join raises ThreadError if target therad is a current or main thread.
|
||||||
|
|
||||||
* Time
|
* Time
|
||||||
* change return value:
|
* change return value:
|
||||||
|
@ -881,4 +881,12 @@ class TestThreadGroup < Test::Unit::TestCase
|
|||||||
Thread.current.join
|
Thread.current.join
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_thread_join_main_thread
|
||||||
|
assert_raises(ThreadError) do
|
||||||
|
Thread.new(Thread.current) {|t|
|
||||||
|
t.join
|
||||||
|
}.join
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
3
thread.c
3
thread.c
@ -739,6 +739,9 @@ thread_join(rb_thread_t *target_th, double delay)
|
|||||||
if (th == target_th) {
|
if (th == target_th) {
|
||||||
rb_raise(rb_eThreadError, "Target thread must not be current thread");
|
rb_raise(rb_eThreadError, "Target thread must not be current thread");
|
||||||
}
|
}
|
||||||
|
if (GET_VM()->main_thread == target_th) {
|
||||||
|
rb_raise(rb_eThreadError, "Target thread must not be main thread");
|
||||||
|
}
|
||||||
|
|
||||||
arg.target = target_th;
|
arg.target = target_th;
|
||||||
arg.waiting = th;
|
arg.waiting = th;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user