cec: fix possible deadlock when starting a new thread
authorLars Op den Kamp <lars@opdenkamp.eu>
Sat, 8 Oct 2011 15:34:23 +0000 (17:34 +0200)
committerLars Op den Kamp <lars@opdenkamp.eu>
Sat, 8 Oct 2011 15:34:23 +0000 (17:34 +0200)
src/lib/platform/threads.cpp

index 31a0fb31571e4c3d49c6e077bf56d155b18d8748..8ba391920feb2695326b52ca6e7467f033771dd1 100644 (file)
@@ -175,10 +175,17 @@ void *CThread::ThreadHandler(CThread *thread)
 
   if (thread)
   {
+    CLockObject lock(&thread->m_threadMutex);
     thread->m_bRunning = true;
+    lock.Leave();
     thread->m_threadCondition.Broadcast();
+
     retVal = thread->Process();
+
+    lock.Lock();
     thread->m_bRunning = false;
+    lock.Leave();
+    thread->m_threadCondition.Broadcast();
   }
 
   return retVal;