[patch] Windows/Win32 thread handle leak with threads join
Kevin Chase [Sun, 6 Jun 2004 09:44:44 +0000 (02:44 -0700)]
From: "Kevin Chase" <kevincha99@hotmail.com>
Message-ID: <BAY2-F172Ih5h5xf4rJ0001a3a6@hotmail.com>

p4raw-id: //depot/perl@22918

ext/threads/threads.xs

index 9d4b2bb..e52143d 100755 (executable)
@@ -150,6 +150,11 @@ Perl_ithread_destruct (pTHX_ ithread* thread, const char *why)
        }
        MUTEX_UNLOCK(&thread->mutex);
        MUTEX_DESTROY(&thread->mutex);
+#ifdef WIN32
+       if (thread->handle)
+           CloseHandle(thread->handle);
+       thread->handle = 0;
+#endif
         PerlMemShared_free(thread);
         if (freeperl)
             perl_free(freeperl);
@@ -566,6 +571,8 @@ Perl_ithread_join(pTHX_ SV *obj)
        MUTEX_UNLOCK(&thread->mutex);
 #ifdef WIN32
        waitcode = WaitForSingleObject(thread->handle, INFINITE);
+       CloseHandle(thread->handle);
+       thread->handle = 0;
 #else
        pthread_join(thread->thr,&retval);
 #endif