From c6f5fc2de190dfb19fa8f02de71934bf85db3147 Mon Sep 17 00:00:00 2001 From: ko1 Date: Thu, 12 Apr 2007 08:14:54 +0000 Subject: * thread.c (mutex_try_lock): check and set owner thread. * thread_pthread.ci: fix to show error code in error message. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@12173 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- thread.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'thread.c') diff --git a/thread.c b/thread.c index 68fcf0629..8373318a9 100644 --- a/thread.c +++ b/thread.c @@ -2138,7 +2138,12 @@ mutex_try_lock(VALUE self) mutex_t *mutex; GetMutexVal(self, mutex); + if (mutex->th == GET_THREAD()) { + rb_raise(rb_eThreadError, "deadlock; recursive locking"); + } + if (native_mutex_trylock(&mutex->lock) != EBUSY) { + mutex->th = GET_THREAD(); return Qtrue; } else { -- cgit