From a50745ec922a917513029f3f87bf820827b43f29 Mon Sep 17 00:00:00 2001 From: rpj Date: Thu, 14 Aug 2003 08:53:17 +0000 Subject: Reuse of thread IDs, improved thread ID validation, new tests, bug fixes. --- ptw32_processTerminate.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'ptw32_processTerminate.c') diff --git a/ptw32_processTerminate.c b/ptw32_processTerminate.c index d816a4b..950598d 100644 --- a/ptw32_processTerminate.c +++ b/ptw32_processTerminate.c @@ -62,6 +62,9 @@ ptw32_processTerminate (void) * ------------------------------------------------------ */ { + pthread_t thread, + nextThread; + if (ptw32_processInitialized) { @@ -85,6 +88,18 @@ ptw32_processTerminate (void) ptw32_cleanupKey = NULL; } + EnterCriticalSection(&ptw32_thread_reuse_lock); + + thread = ptw32_threadReuseTop; + while (thread != PTW32_THREAD_REUSE_BOTTOM) + { + nextThread = thread->prevReuse; + free(thread); + thread = nextThread; + } + + LeaveCriticalSection(&ptw32_thread_reuse_lock); + /* * Destroy the global locks. */ @@ -93,6 +108,7 @@ ptw32_processTerminate (void) DeleteCriticalSection(&ptw32_cond_test_init_lock); DeleteCriticalSection(&ptw32_cond_list_lock); DeleteCriticalSection(&ptw32_mutex_test_init_lock); + DeleteCriticalSection(&ptw32_thread_reuse_lock); ptw32_processInitialized = FALSE; } -- cgit v1.2.3