From fd72cb63bf54c588293887bf80ec719712d5e5bc Mon Sep 17 00:00:00 2001 From: Jeff Hill Date: Fri, 11 Feb 2011 16:33:58 -0600 Subject: [PATCH] libCom/WIN32: Merged Jeff's fix for bug 717252 o Fixed race condition where win32 thread parm was not pushed onto the list before the thread was started, and so if the thread exits very quickly it can try to remove a non-existent thread parameter from the list. o This impacts only win32. --- src/libCom/osi/os/WIN32/osdThread.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/libCom/osi/os/WIN32/osdThread.c b/src/libCom/osi/os/WIN32/osdThread.c index ff8b350ec..b7d63a787 100644 --- a/src/libCom/osi/os/WIN32/osdThread.c +++ b/src/libCom/osi/os/WIN32/osdThread.c @@ -630,18 +630,21 @@ epicsShareFunc epicsThreadId epicsShareAPI epicsThreadCreate (const char *pName, free ( pParmWIN32 ); return NULL; } + + EnterCriticalSection ( & pGbl->mutex ); + ellAdd ( & pGbl->threadList, & pParmWIN32->node ); + LeaveCriticalSection ( & pGbl->mutex ); wstat = ResumeThread ( pParmWIN32->handle ); if (wstat==0xFFFFFFFF) { + EnterCriticalSection ( & pGbl->mutex ); + ellDelete ( & pGbl->threadList, & pParmWIN32->node ); + LeaveCriticalSection ( & pGbl->mutex ); CloseHandle ( pParmWIN32->handle ); free ( pParmWIN32 ); return NULL; } - EnterCriticalSection ( & pGbl->mutex ); - ellAdd ( & pGbl->threadList, & pParmWIN32->node ); - LeaveCriticalSection ( & pGbl->mutex ); - return ( epicsThreadId ) pParmWIN32; }