Fix racy modification of ForThread::m_state during invocation of stop()

This commit is contained in:
grundman 2015-10-16 11:19:27 -07:00
parent 37ce3b8cfe
commit f260b13a6f

View File

@ -304,14 +304,18 @@ void ForThread::stop()
{
if(m_state == eFTStarted)
{
pthread_mutex_lock(&m_thread_mutex);
m_state = eFTToStop;
pthread_mutex_unlock(&m_thread_mutex);
run();
pthread_join(m_posix_thread, NULL);
}
pthread_mutex_lock(&m_thread_mutex);
m_state = eFTStoped;
pthread_mutex_unlock(&m_thread_mutex);
}
void ForThread::run()