Skip to content

Commit

Permalink
Merge pull request #16 from Lastique/fix_pthread_late_set_is_running
Browse files Browse the repository at this point in the history
Set `PThread::m_isRunning` early, when the thread is created
  • Loading branch information
willamowius committed Feb 21, 2022
2 parents d4f29f2 + 646d25f commit b554f42
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/ptlib/unix/tlibthrd.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -496,10 +496,9 @@ PThread::~PThread()


void * PThread::PX_ThreadStart(void * arg)
{
{
PThread * thread = (PThread *)arg;
SetCurrentThread(thread);
__atomic_store_n(&thread->m_isRunning, true, __ATOMIC_RELAXED);
// Added this to guarantee that the thread creation (PThread::Restart)
// has completed before we start the thread. Then the m_threadId has
// been set.
Expand Down Expand Up @@ -589,6 +588,7 @@ void PThread::Restart()
// create the thread
PAssertPTHREAD(pthread_create, (&m_threadId, &threadAttr, PX_ThreadStart, this));
m_threadIdValid = true;
__atomic_store_n(&m_isRunning, true, __ATOMIC_RELAXED);

// put the thread into the thread list
process.PXSetThread(m_threadId, this);
Expand Down

0 comments on commit b554f42

Please sign in to comment.