summaryrefslogtreecommitdiffstats
path: root/ext
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-03-16 11:31:00 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-03-16 11:31:00 +0000
commitd0244d23268fa6a9959da1c153a78dc719f204fe (patch)
tree007952b0ff9087e06bff025d51773a427adc634e /ext
parent62cba2e11cfc2cdeb5ea6766f1cd69c38ea02164 (diff)
downloadruby-d0244d23268fa6a9959da1c153a78dc719f204fe.tar.gz
ruby-d0244d23268fa6a9959da1c153a78dc719f204fe.tar.xz
ruby-d0244d23268fa6a9959da1c153a78dc719f204fe.zip
* merge -r 12066:12069
git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8_6@12077 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r--ext/thread/thread.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/ext/thread/thread.c b/ext/thread/thread.c
index e9dde37a1..d617185a2 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