diff options
author | shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-05-18 04:56:22 +0000 |
---|---|---|
committer | shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-05-18 04:56:22 +0000 |
commit | 7be5169804ee0cfe1991903fa10c31f8bd6525bd (patch) | |
tree | 0b8129f5a0b2fc9a19d6b12ae5eb966b7a6e2128 /test/monitor | |
parent | 47349e870111b8ae88bd1331559a022be88d80ec (diff) | |
download | ruby-7be5169804ee0cfe1991903fa10c31f8bd6525bd.tar.gz |
* lib/monitor.rb (mon_try_enter, mon_enter): should reset @mon_count
just in case the previous owner thread dies without mon_exit.
[fix GH-874] Patch by @chrisberkhout
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50525 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/monitor')
-rw-r--r-- | test/monitor/test_monitor.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/monitor/test_monitor.rb b/test/monitor/test_monitor.rb index 451e26cc7a..088bf28a37 100644 --- a/test/monitor/test_monitor.rb +++ b/test/monitor/test_monitor.rb @@ -33,6 +33,22 @@ class TestMonitor < Test::Unit::TestCase assert_equal((1..10).to_a, ary) end + def test_enter_second_after_killed_thread + th = Thread.start { + @monitor.enter + Thread.current.kill + @monitor.exit + } + th.join + @monitor.enter + @monitor.exit + th2 = Thread.start { + @monitor.enter + @monitor.exit + } + assert_join_threads([th, th2]) + end + def test_synchronize ary = [] queue = Queue.new @@ -111,6 +127,22 @@ class TestMonitor < Test::Unit::TestCase assert_join_threads([th, th2]) end + def test_try_enter_second_after_killed_thread + th = Thread.start { + assert_equal(true, @monitor.try_enter) + Thread.current.kill + @monitor.exit + } + th.join + assert_equal(true, @monitor.try_enter) + @monitor.exit + th2 = Thread.start { + assert_equal(true, @monitor.try_enter) + @monitor.exit + } + assert_join_threads([th, th2]) + end + def test_cond cond = @monitor.new_cond |