harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apetre...@apache.org
Subject svn commit: r488755 - /harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_basic.c
Date Tue, 19 Dec 2006 18:37:38 GMT
Author: apetrenko
Date: Tue Dec 19 10:37:37 2006
New Revision: 488755

URL: http://svn.apache.org/viewvc?view=rev&rev=488755
Log:
Patch for HARMONY-2483 "[drlvm] hythread_detach isn't consistent with the spec"

Modified:
    harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_basic.c

Modified: harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_basic.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_basic.c?view=diff&rev=488755&r1=488754&r2=488755
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_basic.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_basic.c Tue Dec 19 10:37:37 2006
@@ -271,20 +271,29 @@
  * @see hythread_attach
  */
 void VMCALL hythread_detach(hythread_t thread) {
-    // Acquire global TM lock to prevent concurrent acccess to thread list
     IDATA status;
+
+    if (thread == NULL) {
+        thread = hythread_self();
+    }
     
-    assert(thread == tm_self_tls);
+    // Acquire global TM lock to prevent concurrent acccess to thread list
     status = hythread_global_lock(NULL);
     assert (status == TM_ERROR_NONE);
 
-    thread_set_self(NULL);
-    fast_thread_array[thread->thread_id] = NULL;
-
-    thread->prev->next = thread->next;
-    thread->next->prev = thread->prev;
-    thread->group->threads_count--;
-
+    // No actions required in case the specified thread is detached already.
+    if (thread->group != NULL) {
+        assert(thread == tm_self_tls);
+        
+        thread_set_self(NULL);
+        fast_thread_array[thread->thread_id] = NULL;
+        
+        thread->prev->next = thread->next;
+        thread->next->prev = thread->prev;
+        thread->group->threads_count--;
+        thread->group = NULL;
+    }
+    
     hythread_global_unlock(NULL);
     assert(status == TM_ERROR_NONE);
 }



Mime
View raw message