[macruby-changes] [5264] MacRuby/trunk/vm.cpp

source_changes at macosforge.org source_changes at macosforge.org
Mon Mar 7 19:31:53 PST 2011


Revision: 5264
          http://trac.macosforge.org/projects/ruby/changeset/5264
Author:   watson1978 at 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"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20110307/8faf8d3e/attachment-0001.html>


More information about the macruby-changes mailing list