Revision: 5264 http://trac.macosforge.org/projects/ruby/changeset/5264 Author: watson1978@gmail.com Date: 2011-03-07 19:31:53 -0800 (Mon, 07 Mar 2011) Log Message: ----------- Thread#kill cancels safely the Thread in while Thread is handling termination. Fix #794. Modified Paths: -------------- MacRuby/trunk/vm.cpp Modified: MacRuby/trunk/vm.cpp =================================================================== --- MacRuby/trunk/vm.cpp 2011-03-07 22:19:04 UTC (rev 5263) +++ MacRuby/trunk/vm.cpp 2011-03-08 03:31:53 UTC (rev 5264) @@ -4745,10 +4745,14 @@ void rb_vm_thread_cancel(rb_vm_thread_t *t) { + RoxorCoreLock lock; + if (t->status != THREAD_KILLED && t->status != THREAD_DEAD) { t->status = THREAD_KILLED; if (t->thread == pthread_self()) { + lock.unlock(); rb_vm_thread_throw_kill(); + return; } else { pthread_assert(pthread_mutex_lock(&t->sleep_mutex)); @@ -4767,6 +4771,7 @@ pthread_assert(pthread_mutex_unlock(&t->sleep_mutex)); } } + lock.unlock(); } extern "C"