posix: set the timeout when writing to the serial port
[deb_libcec.git] / 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;