From e27ef85f5c8fdaf8d1276d6a4d48bd46bc502596 Mon Sep 17 00:00:00 2001 From: shyouhei Date: Fri, 16 Mar 2007 11:31:00 +0000 Subject: * merge -r 12066:12069 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_6@12077 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/thread/thread.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'ext') diff --git a/ext/thread/thread.c b/ext/thread/thread.c index e9dde37a18..d617185a26 100644 --- a/ext/thread/thread.c +++ b/ext/thread/thread.c @@ -390,7 +390,7 @@ rb_mutex_try_lock(VALUE self) * */ -static void +static VALUE lock_mutex(Mutex *mutex) { VALUE current; @@ -405,6 +405,7 @@ lock_mutex(Mutex *mutex) mutex->owner = current; rb_thread_critical = 0; + return Qnil; } static VALUE @@ -429,8 +430,13 @@ unlock_mutex_inner(Mutex *mutex) VALUE waking; if (!RTEST(mutex->owner)) { - return Qundef; + rb_raise(rb_eThreadError, "not owner"); } + + if (mutex->owner != rb_thread_current()) { + rb_raise(rb_eThreadError, "not owner"); + } + mutex->owner = Qnil; waking = wake_one(&mutex->waiting); @@ -623,18 +629,12 @@ static void wait_condvar(ConditionVariable *condvar, Mutex *mutex) { rb_thread_critical = 1; - if (!RTEST(mutex->owner)) { - rb_thread_critical = 0; - return; - } - if (mutex->owner != rb_thread_current()) { + if (rb_thread_current() != mutex->owner) { rb_thread_critical = 0; - rb_raise(rb_eThreadError, "Not owner"); + rb_raise(rb_eThreadError, "not owner of the synchronization mutex"); } - mutex->owner = Qnil; - wait_list(&condvar->waiting); - - lock_mutex(mutex); + unlock_mutex_inner(mutex); + rb_ensure(wait_list, (VALUE)&condvar->waiting, lock_mutex, (VALUE)mutex); } static VALUE -- cgit v1.2.3