summaryrefslogtreecommitdiff
path: root/thread.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-04-12 08:14:54 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-04-12 08:14:54 +0000
commit0089455e53628edf94060b56203279ad59c32553 (patch)
treefb38b6f2fe8a01adc8cfdabad03d8ae7e30f52b0 /thread.c
parente0943c481ab3fc3a5a35e3f7a71d97ad93f7036f (diff)
* thread.c (mutex_try_lock): check and set owner thread.
* thread_pthread.ci: fix to show error code in error message. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12173 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread.c')
-rw-r--r--thread.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/thread.c b/thread.c
index 68fcf06294..8373318a9e 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 {