From b68f47927ca9be0a59dab157a733480aabd67f6c Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Tue, 24 Sep 2019 20:21:56 -0700 Subject: [PATCH] WIN32 remove atexit cleanup of TLS Force cleanup of resource for threads which may still be running opens the possibility of strange race conditions. Like threads be erroneously detected as non-epics. Doing this cleanup at process exit serves no real purpose. This code might be valid to re-add in a DLL exit handler. --- modules/libcom/src/osi/os/WIN32/osdThread.c | 29 --------------------- 1 file changed, 29 deletions(-) diff --git a/modules/libcom/src/osi/os/WIN32/osdThread.c b/modules/libcom/src/osi/os/WIN32/osdThread.c index 1cfa1ec5c..f86c5e8ac 100644 --- a/modules/libcom/src/osi/os/WIN32/osdThread.c +++ b/modules/libcom/src/osi/os/WIN32/osdThread.c @@ -37,7 +37,6 @@ epicsShareFunc void osdThreadHooksRun(epicsThreadId id); void setThreadName ( DWORD dwThreadID, LPCSTR szThreadName ); -static void threadCleanupWIN32 ( void ); typedef struct win32ThreadGlobal { CRITICAL_SECTION mutex; @@ -218,15 +217,6 @@ static win32ThreadGlobal * fetchWin32ThreadGlobal ( void ) return 0; } - crtlStatus = atexit ( threadCleanupWIN32 ); - if ( crtlStatus ) { - TlsFree ( pWin32ThreadGlobal->tlsIndexThreadLibraryEPICS ); - DeleteCriticalSection ( & pWin32ThreadGlobal->mutex ); - free ( pWin32ThreadGlobal ); - pWin32ThreadGlobal = 0; - return 0; - } - InterlockedExchange ( & initCompleted, 1 ); return pWin32ThreadGlobal; @@ -254,25 +244,6 @@ static void epicsParmCleanupWIN32 ( win32ThreadParam * pParm ) } } -/* - * threadCleanupWIN32 () - */ -static void threadCleanupWIN32 ( void ) -{ - win32ThreadGlobal * pGbl = fetchWin32ThreadGlobal (); - win32ThreadParam * pParm; - - if ( ! pGbl ) { - fprintf ( stderr, "threadCleanupWIN32: unable to find ctx\n" ); - return; - } - - while ( ( pParm = ( win32ThreadParam * ) - ellFirst ( & pGbl->threadList ) ) ) { - epicsParmCleanupWIN32 ( pParm ); - } -} - /* * epicsThreadExitMain () */