Skip to content

Commit

Permalink
Thread#kill cancels safely the Thread in while Thread is handling ter…
Browse files Browse the repository at this point in the history
…mination. Fix #794.

git-svn-id: http://svn.macosforge.org/repository/ruby/MacRuby/trunk@5264 23306eb0-4c56-4727-a40e-e92c0eb68959
  • Loading branch information
Watson1978 committed Mar 8, 2011
1 parent 4efb798 commit 828dc8a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions vm.cpp
Expand Up @@ -4745,10 +4745,14 @@ extern "C"
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));
Expand All @@ -4767,6 +4771,7 @@ rb_vm_thread_cancel(rb_vm_thread_t *t)
pthread_assert(pthread_mutex_unlock(&t->sleep_mutex));
}
}
lock.unlock();
}

extern "C"
Expand Down

0 comments on commit 828dc8a

Please sign in to comment.