re PR libgcj/14751 ([win32] thread creation leaks system handle resources)
authorMohan Embar <gnustuff@thisiscool.com>
Sat, 11 Sep 2004 19:13:51 +0000 (19:13 +0000)
committerMohan Embar <membar@gcc.gnu.org>
Sat, 11 Sep 2004 19:13:51 +0000 (19:13 +0000)
PR libgcj/14751
* win32-threads.cc (_Jv_ThreadInitData): Zero out thread
handle in newly-allocated _Jv_Thread_t.
(_Jv_ThreadDestroyData): Close thread handle.
(_Jv_ThreadStart): Remove obsolete comment.
Store handle of newly-created thread in _Jv_Thread_t.
* include/win32-threads.h: #define WIN32_LEAN_AND_MEAN
before including <windows.h>
#define _Jv_HaveCondDestroy

From-SVN: r87362

libjava/ChangeLog
libjava/include/win32-threads.h
libjava/win32-threads.cc

index d3a6cea9bbae9c403ac2a9c403305248adf641ec..cc796b163fe1953ec199d64bbdff7c7a73f13095 100644 (file)
@@ -1,3 +1,15 @@
+2004-09-11  Mohan Embar  <gnustuff@thisiscool.com>
+
+       PR libgcj/14751
+       * win32-threads.cc (_Jv_ThreadInitData): Zero out thread
+       handle in newly-allocated _Jv_Thread_t.
+       (_Jv_ThreadDestroyData): Close thread handle.
+       (_Jv_ThreadStart): Remove obsolete comment.
+       Store handle of newly-created thread in _Jv_Thread_t.
+       * include/win32-threads.h: #define WIN32_LEAN_AND_MEAN
+       before including <windows.h>
+       #define _Jv_HaveCondDestroy
+
 2004-09-11  Mohan Embar  <gnustuff@thisiscool.com>
 
        * java/lang/natThread.cc (finalize_native): Destroy
index fdd21c541b4b22f8eccb34d50a3d7541c55e6292..ba9def10d6815cee80dc74b2a662467de7ce7bfd 100644 (file)
@@ -13,6 +13,7 @@ details.  */
 #ifndef __JV_WIN32_THREADS__
 #define __JV_WIN32_THREADS__
 
+#define WIN32_LEAN_AND_MEAN
 #include <windows.h>
 
 //
@@ -75,6 +76,7 @@ typedef void _Jv_ThreadStartFunc (java::lang::Thread *);
 // Condition variables.
 //
 
+#define _Jv_HaveCondDestroy
 int _Jv_CondWait (_Jv_ConditionVariable_t *cv, _Jv_Mutex_t *mu, jlong millis, jint nanos);
 void _Jv_CondInit (_Jv_ConditionVariable_t *cv);
 void _Jv_CondDestroy (_Jv_ConditionVariable_t *cv);
index 9e3981db3ddcf316e08ed3ad1d9fafbd56f5c7cf..35a16cdb6ace39be099568f3adc2deb62594991e 100644 (file)
@@ -262,6 +262,7 @@ _Jv_ThreadInitData (java::lang::Thread* obj)
 {
   _Jv_Thread_t *data = (_Jv_Thread_t*)_Jv_Malloc(sizeof(_Jv_Thread_t));
   data->flags = 0;
+  data->handle = 0;
   data->thread_obj = obj;
   data->interrupt_event = 0;
   InitializeCriticalSection (&data->interrupt_mutex);
@@ -275,6 +276,7 @@ _Jv_ThreadDestroyData (_Jv_Thread_t *data)
   DeleteCriticalSection (&data->interrupt_mutex);
   if (data->interrupt_event)
     CloseHandle(data->interrupt_event);
+  CloseHandle(data->handle);
   _Jv_Free(data);
 }
 
@@ -365,7 +367,6 @@ _Jv_ThreadStart (java::lang::Thread *thread, _Jv_Thread_t *data, _Jv_ThreadStart
     return;
   data->flags |= FLAG_START;
 
-  // FIXME: handle marking the info object for GC.
   info = (struct starter *) _Jv_AllocBytes (sizeof (struct starter));
   info->method = meth;
   info->data = data;
@@ -379,7 +380,7 @@ _Jv_ThreadStart (java::lang::Thread *thread, _Jv_Thread_t *data, _Jv_ThreadStart
   else
     data->flags |= FLAG_DAEMON;
 
-  GC_CreateThread(NULL, 0, really_start, info, 0, &id);
+  data->handle = GC_CreateThread(NULL, 0, really_start, info, 0, &id);
   _Jv_ThreadSetPriority(data, thread->getPriority());
 }