diff options
| author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-04-13 09:52:29 +0000 |
|---|---|---|
| committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-04-13 09:52:29 +0000 |
| commit | ff470e30fb0999fd5d2510559a5b4f84cfc12f7f (patch) | |
| tree | 907cac3ef98d7ccb52ac81af4edc07c3de7286cf /thread.c | |
| parent | 775f40c3dcb6fb4844e4566c1ecf8613403b5d75 (diff) | |
| download | ruby-ff470e30fb0999fd5d2510559a5b4f84cfc12f7f.tar.gz ruby-ff470e30fb0999fd5d2510559a5b4f84cfc12f7f.tar.xz ruby-ff470e30fb0999fd5d2510559a5b4f84cfc12f7f.zip | |
* thread_pthread.c (lock_func): should not check interrupts in
blocking region. [ruby-dev:34378]
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@15990 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread.c')
| -rw-r--r-- | thread.c | 22 |
1 files changed, 13 insertions, 9 deletions
@@ -2317,23 +2317,23 @@ rb_mutex_trylock(VALUE self) return locked; } -static VALUE +static int lock_func(rb_thread_t *th, mutex_t *mutex) { + int interrupted = Qfalse; + native_mutex_lock(&mutex->lock); - while (mutex->th) { + while (mutex->th || (mutex->th = th, 0)) { mutex->cond_waiting++; native_cond_wait(&mutex->cond, &mutex->lock); if (th->interrupt_flag) { - native_mutex_unlock(&mutex->lock); - RUBY_VM_CHECK_INTS(); - native_mutex_lock(&mutex->lock); + interrupted = Qtrue; + break; } } - mutex->th = th; native_mutex_unlock(&mutex->lock); - return Qnil; + return interrupted; } static void @@ -2364,11 +2364,15 @@ rb_mutex_lock(VALUE self) GetMutexPtr(self, mutex); while (mutex->th != th) { + int interrupted; + BLOCKING_REGION({ - lock_func(th, mutex); + interrupted = lock_func(th, mutex); }, lock_interrupt, mutex); - RUBY_VM_CHECK_INTS(); + if (interrupted) { + RUBY_VM_CHECK_INTS(); + } } } return self; |
