[Opalvoip-svn] SF.net SVN: opalvoip:[34856] ptlib/trunk
Brought to you by:
csoutheren,
rjongbloed
From: <rjo...@us...> - 2016-07-05 07:59:54
|
Revision: 34856 http://sourceforge.net/p/opalvoip/code/34856 Author: rjongbloed Date: 2016-07-05 07:59:51 +0000 (Tue, 05 Jul 2016) Log Message: ----------- Merged revision(s) 34840-34855 from ptlib/branches/v2_16: Fixed race condition handling removing of auto delete threads, thanks Derek Smithies Modified Paths: -------------- ptlib/trunk/src/ptlib/common/osutils.cxx Property Changed: ---------------- ptlib/trunk/ Index: ptlib/trunk =================================================================== --- ptlib/trunk 2016-07-05 07:56:17 UTC (rev 34855) +++ ptlib/trunk 2016-07-05 07:59:51 UTC (rev 34856) Property changes on: ptlib/trunk ___________________________________________________________________ Modified: svn:mergeinfo ## -6,7 +6,7 ## /ptlib/branches/v2_10:25177-29189,32921,32947 /ptlib/branches/v2_12:28485-31603 /ptlib/branches/v2_14:31501-33720 -/ptlib/branches/v2_16:34085-34839 +/ptlib/branches/v2_16:34085-34855 /ptlib/branches/v2_2:20746,20791,20827,22014,22942 /ptlib/branches/v2_4:21086,21094,21147,21160,21185,21281,21296,21305,21322,21337,21363,21467,21471-21472,21506,21508,21623,21695,21744,21746,21763,22241,22958,23045-23046,23061,23066,23712 /ptlib/branches/v2_6:22195,22243,22295,22304,22311,22317,22320,22356,22458,22509,22587,22601-22602,22611,22629,22633,22673,22681,22729,22731-22732,22736,22742,22848,22960,22992,23161,23163,23167,23169,23177,23239,23291,23298,23336,23429,23595,23823,23827,23873,24816 \ No newline at end of property Modified: ptlib/trunk/src/ptlib/common/osutils.cxx =================================================================== --- ptlib/trunk/src/ptlib/common/osutils.cxx 2016-07-05 07:56:17 UTC (rev 34855) +++ ptlib/trunk/src/ptlib/common/osutils.cxx 2016-07-05 07:59:51 UTC (rev 34856) @@ -2540,17 +2540,20 @@ if (PAssertNULL(thread) == NULL) return; - if (thread->IsAutoDelete()) { - PTRACE(5, thread, "Queuing auto-delete of thread " << *thread); - thread->SetNoAutoDelete(); - m_autoDeleteThreads.Enqueue(thread); - } + // Do the log before mutex and thread being removed from m_activeThreads + PTRACE_IF(5, thread->IsAutoDelete(), thread, "Queuing auto-delete of thread " << *thread); PWaitAndSignal mutex(m_threadMutex); ThreadMap::iterator it = m_activeThreads.find(thread->GetThreadId()); if (it != m_activeThreads.end() && it->second == thread) m_activeThreads.erase(it); // Not already gone, or re-used the thread ID for new thread. + + // Must be last thing to avoid race condition + if (thread->IsAutoDelete()) { + thread->SetNoAutoDelete(); + m_autoDeleteThreads.Enqueue(thread); + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |