From 38ba839eb35987e47b98f795fbdc6083ab48921c Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 25 Aug 2016 23:31:18 +0100 Subject: watchdog timeouts: replace a silly List copy i added doing it a better way --- OpenSim/Framework/Monitoring/Watchdog.cs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/Monitoring/Watchdog.cs b/OpenSim/Framework/Monitoring/Watchdog.cs index b2c1fb1..ff439f5 100644 --- a/OpenSim/Framework/Monitoring/Watchdog.cs +++ b/OpenSim/Framework/Monitoring/Watchdog.cs @@ -332,18 +332,18 @@ namespace OpenSim.Framework.Monitoring if (callback != null) { List callbackInfos = null; - List threadsInfo; + List threadsToRemove = null; lock (m_threads) { - // get a copy since we may change m_threads - threadsInfo = m_threads.Values.ToList(); - - foreach(ThreadWatchdogInfo threadInfo in threadsInfo) + foreach(ThreadWatchdogInfo threadInfo in m_threads.Values) { if(threadInfo.Thread.ThreadState == ThreadState.Stopped) { - RemoveThread(threadInfo.Thread.ManagedThreadId); + if(threadsToRemove == null) + threadsToRemove = new List(); + + threadsToRemove.Add(threadInfo); if(callbackInfos == null) callbackInfos = new List(); @@ -365,6 +365,10 @@ namespace OpenSim.Framework.Monitoring } } } + + if(threadsToRemove != null) + foreach(ThreadWatchdogInfo twi in threadsToRemove) + RemoveThread(twi.Thread.ManagedThreadId); } if(callbackInfos != null) -- cgit v1.1