harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gshiman...@apache.org
Subject svn commit: r597426 - in /harmony/enhanced/drlvm/trunk/vm/thread/src: linux/os_thread.c thread_native_basic.c thread_private.h win/os_thread.c
Date Thu, 22 Nov 2007 15:21:31 GMT
Author: gshimansky
Date: Thu Nov 22 07:21:31 2007
New Revision: 597426

URL: http://svn.apache.org/viewvc?rev=597426&view=rev
Log:
Fixed thread handles leak described in HARMONY-4958. When thread block is
reused, OS handle for the thread should be closed.


Modified:
    harmony/enhanced/drlvm/trunk/vm/thread/src/linux/os_thread.c
    harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_basic.c
    harmony/enhanced/drlvm/trunk/vm/thread/src/thread_private.h
    harmony/enhanced/drlvm/trunk/vm/thread/src/win/os_thread.c

Modified: harmony/enhanced/drlvm/trunk/vm/thread/src/linux/os_thread.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/thread/src/linux/os_thread.c?rev=597426&r1=597425&r2=597426&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/thread/src/linux/os_thread.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/thread/src/linux/os_thread.c Thu Nov 22 07:21:31 2007
@@ -134,6 +134,18 @@
 }
 
 /**
+ * Not used on Linux
+ *
+ * @param os_thread     thread handle
+ *
+ * @return              0 on success, systerm error otherwise
+ */
+int os_thread_free(osthread_t os_thread)
+{
+    return 0;
+}
+
+/**
  * Joins the os thread.
  *
  * @param os_thread     thread handle

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?rev=597426&r1=597425&r2=597426&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_basic.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_basic.c Thu Nov 22 07:21:31 2007
@@ -594,7 +594,7 @@
     IDATA status;
 
     assert(new_thread);
-    if (!new_thread->stacksize) {
+    if (!new_thread->os_handle) {
         // Create thread primitives
         status = hylatch_create(&new_thread->join_event, 1);
         assert(status == TM_ERROR_NONE);
@@ -605,6 +605,10 @@
         status = hycond_create(&new_thread->condition);
         assert(status == TM_ERROR_NONE);
         new_thread->stacksize = os_get_foreign_thread_stack_size();
+    } else {
+        // This join should also delete thread OS handle
+        int result = os_thread_free(new_thread->os_handle);
+        assert(0 == result);
     }
 
     new_thread->os_handle  = (osthread_t)NULL;

Modified: harmony/enhanced/drlvm/trunk/vm/thread/src/thread_private.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_private.h?rev=597426&r1=597425&r2=597426&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/thread/src/thread_private.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/thread/src/thread_private.h Thu Nov 22 07:21:31 2007
@@ -311,6 +311,7 @@
 int os_thread_set_priority(osthread_t thread, int priority);
 osthread_t os_thread_current();
 int os_thread_cancel(osthread_t);
+int os_thread_free(osthread_t os_thread);
 void os_thread_exit(IDATA status);
 void os_thread_yield_other(osthread_t);
 int os_get_thread_times(osthread_t os_thread, int64* pkernel, int64* puser);

Modified: harmony/enhanced/drlvm/trunk/vm/thread/src/win/os_thread.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/thread/src/win/os_thread.c?rev=597426&r1=597425&r2=597426&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/thread/src/win/os_thread.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/thread/src/win/os_thread.c Thu Nov 22 07:21:31 2007
@@ -84,6 +84,19 @@
 }
 
 /**
+ * Free native thread handle
+ *
+ * @param os_thread     thread handle
+ *
+ * @return              0 on success, systerm error otherwise
+ */
+int os_thread_free(osthread_t os_thread)
+{
+    BOOL r = CloseHandle(os_thread);
+    return !r;
+}
+
+/**
  * Joins the os thread.
  *
  * @param os_thread     thread handle



Mime
View raw message