Fix racy modification of ForThread::m_state during invocation of stop()
This commit is contained in:
parent
37ce3b8cfe
commit
f260b13a6f
@ -304,14 +304,18 @@ void ForThread::stop()
|
|||||||
{
|
{
|
||||||
if(m_state == eFTStarted)
|
if(m_state == eFTStarted)
|
||||||
{
|
{
|
||||||
|
pthread_mutex_lock(&m_thread_mutex);
|
||||||
m_state = eFTToStop;
|
m_state = eFTToStop;
|
||||||
|
pthread_mutex_unlock(&m_thread_mutex);
|
||||||
|
|
||||||
run();
|
run();
|
||||||
|
|
||||||
pthread_join(m_posix_thread, NULL);
|
pthread_join(m_posix_thread, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pthread_mutex_lock(&m_thread_mutex);
|
||||||
m_state = eFTStoped;
|
m_state = eFTStoped;
|
||||||
|
pthread_mutex_unlock(&m_thread_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ForThread::run()
|
void ForThread::run()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user