mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/thread/thread.c (wait_condvar, lock_mutex): Fix a problem in
ConditionVariable#wait that occurs when two threads that are trying to access the condition variable are also in concurrence for the given mutex; submitted by: Sylvain Joyeux <sylvain.joyeux AT m4x.org> and MenTaLguY <mental AT rydia.net> in [ruby-core:10598]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@12068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
89150c9ecb
commit
15b97d196a
2 changed files with 15 additions and 11 deletions
|
@ -1,3 +1,12 @@
|
|||
Fri Mar 16 16:21:35 2007 Akinori MUSHA <knu@iDaemons.org>
|
||||
|
||||
* ext/thread/thread.c (wait_condvar, lock_mutex): Fix a problem in
|
||||
ConditionVariable#wait that occurs when two threads that are
|
||||
trying to access the condition variable are also in concurrence
|
||||
for the given mutex; submitted by: Sylvain Joyeux
|
||||
<sylvain.joyeux AT m4x.org> and MenTaLguY <mental AT rydia.net>
|
||||
in [ruby-core:10598].
|
||||
|
||||
Fri Mar 16 16:17:27 2007 Akinori MUSHA <knu@iDaemons.org>
|
||||
|
||||
* test/thread/test_thread.rb: Add a test script for the `thread'
|
||||
|
|
|
@ -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
|
||||
|
@ -623,18 +624,12 @@ static void
|
|||
wait_condvar(ConditionVariable *condvar, Mutex *mutex)
|
||||
{
|
||||
rb_thread_critical = 1;
|
||||
if (!RTEST(mutex->owner)) {
|
||||
if (rb_thread_current() != mutex->owner) {
|
||||
rb_thread_critical = 0;
|
||||
return;
|
||||
rb_raise(rb_eThreadError, "not owner of the synchronization mutex");
|
||||
}
|
||||
if (mutex->owner != rb_thread_current()) {
|
||||
rb_thread_critical = 0;
|
||||
rb_raise(rb_eThreadError, "Not owner");
|
||||
}
|
||||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue