watchdog timeouts: replace a silly List copy i added doing it a better way
parent
d5f376a4b1
commit
38ba839eb3
|
@ -332,18 +332,18 @@ namespace OpenSim.Framework.Monitoring
|
||||||
if (callback != null)
|
if (callback != null)
|
||||||
{
|
{
|
||||||
List<ThreadWatchdogInfo> callbackInfos = null;
|
List<ThreadWatchdogInfo> callbackInfos = null;
|
||||||
List<ThreadWatchdogInfo> threadsInfo;
|
List<ThreadWatchdogInfo> threadsToRemove = null;
|
||||||
|
|
||||||
lock (m_threads)
|
lock (m_threads)
|
||||||
{
|
{
|
||||||
// get a copy since we may change m_threads
|
foreach(ThreadWatchdogInfo threadInfo in m_threads.Values)
|
||||||
threadsInfo = m_threads.Values.ToList();
|
|
||||||
|
|
||||||
foreach(ThreadWatchdogInfo threadInfo in threadsInfo)
|
|
||||||
{
|
{
|
||||||
if(threadInfo.Thread.ThreadState == ThreadState.Stopped)
|
if(threadInfo.Thread.ThreadState == ThreadState.Stopped)
|
||||||
{
|
{
|
||||||
RemoveThread(threadInfo.Thread.ManagedThreadId);
|
if(threadsToRemove == null)
|
||||||
|
threadsToRemove = new List<ThreadWatchdogInfo>();
|
||||||
|
|
||||||
|
threadsToRemove.Add(threadInfo);
|
||||||
|
|
||||||
if(callbackInfos == null)
|
if(callbackInfos == null)
|
||||||
callbackInfos = new List<ThreadWatchdogInfo>();
|
callbackInfos = new List<ThreadWatchdogInfo>();
|
||||||
|
@ -365,6 +365,10 @@ namespace OpenSim.Framework.Monitoring
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(threadsToRemove != null)
|
||||||
|
foreach(ThreadWatchdogInfo twi in threadsToRemove)
|
||||||
|
RemoveThread(twi.Thread.ManagedThreadId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(callbackInfos != null)
|
if(callbackInfos != null)
|
||||||
|
|
Loading…
Reference in New Issue