summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-12-29 03:03:09 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-12-29 03:03:09 +0000
commitb2ad49565f10dfdd594680c2fa7a4af81c1027fe (patch)
tree840c36be0f50cc01ff145a9d56b095c05304652f /test
parenta928613a313e7750c7dcee824631cd6ed1690344 (diff)
* thread.c (rb_mutex_trylock): return false if Mutex owned
by current thread. [ruby-core:20943] * thread.c (rb_mutex_lock): check dead lock (recursive lock) here. * test/ruby/test_thread.rb: add a test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21148 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_thread.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/ruby/test_thread.rb b/test/ruby/test_thread.rb
index 97e58cd9ea..b460cadea9 100644
--- a/test/ruby/test_thread.rb
+++ b/test/ruby/test_thread.rb
@@ -438,6 +438,18 @@ class TestThread < Test::Unit::TestCase
assert_equal(false, m3.locked?)
end
+ def test_mutex_trylock
+ m = Mutex.new
+ assert_equal(true, m.try_lock)
+ assert_equal(false, m.try_lock, '[ruby-core:20943]')
+
+ Thread.new{
+ assert_equal(false, m.try_lock)
+ }.join
+
+ m.unlock
+ end
+
def test_recursive_error
o = Object.new
def o.inspect