Revision: 23363
http://opalvoip.svn.sourceforge.net/opalvoip/?rev=23363&view=rev
Author: rjongbloed
Date: 2009-09-07 23:22:36 +0000 (Mon, 07 Sep 2009)
Log Message:
-----------
Yet another change to the thread map handling to remove the small chance of accessing a deleting object on a auto-delete thread.
Modified Paths:
--------------
ptlib/trunk/src/ptlib/unix/tlibthrd.cxx
Modified: ptlib/trunk/src/ptlib/unix/tlibthrd.cxx
===================================================================
--- ptlib/trunk/src/ptlib/unix/tlibthrd.cxx 2009-09-07 12:45:55 UTC (rev 23362)
+++ ptlib/trunk/src/ptlib/unix/tlibthrd.cxx 2009-09-07 23:22:36 UTC (rev 23363)
@@ -133,22 +133,24 @@
process.m_activeThreadMutex.Wait();
PBoolean found;
do {
- found = PFalse;
+ found = false;
for (PProcess::ThreadMap::iterator it = process.m_activeThreads.begin(); it != process.m_activeThreads.end(); ++it) {
- PThread & thread = *it->second;
- if (thread.autoDelete && thread.IsTerminated()) {
+ PThread * thread = it->second;
+ if (thread->autoDelete && thread->IsTerminated()) {
+ process.m_activeThreads.erase(it);
+
// unlock the m_activeThreadMutex to avoid deadlocks:
// if somewhere in the destructor a call to PTRACE() is made,
// which itself calls PThread::Current(), deadlocks are possible
process.m_activeThreadMutex.Signal();
- delete it->second;
+ delete thread;
process.m_activeThreadMutex.Wait();
- process.m_activeThreads.erase(it);
- found = PTrue;
+
+ found = true;
break;
}
}
- } while (found == PTrue);
+ } while (found);
process.m_activeThreadMutex.Signal();
process.PXCheckSignals();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|