summaryrefslogtreecommitdiff
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
commite27ef85f5c8fdaf8d1276d6a4d48bd46bc502596 (patch)
tree007952b0ff9087e06bff025d51773a427adc634e /ext
parent6f405ca6a67573d84df65e9792b4ec0b3d90f5c0 (diff)
* 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
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 e9dde37..d617185 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