change wrong watchdog stopped thread check code, and don't log it

0.9.0-post-fixes
UbitUmarov 2017-05-26 00:05:35 +01:00
parent 31b4a31246
commit d90b68c2a6
2 changed files with 10 additions and 5 deletions

View File

@ -341,6 +341,8 @@ namespace OpenSim.Framework.Monitoring
/// <param name="e"></param> /// <param name="e"></param>
private static void WatchdogTimerElapsed(object sender, System.Timers.ElapsedEventArgs e) private static void WatchdogTimerElapsed(object sender, System.Timers.ElapsedEventArgs e)
{ {
if(!m_enabled)
return;
int now = Environment.TickCount & Int32.MaxValue; int now = Environment.TickCount & Int32.MaxValue;
int msElapsed = now - LastWatchdogThreadTick; int msElapsed = now - LastWatchdogThreadTick;
@ -358,21 +360,26 @@ namespace OpenSim.Framework.Monitoring
List<ThreadWatchdogInfo> callbackInfos = null; List<ThreadWatchdogInfo> callbackInfos = null;
List<ThreadWatchdogInfo> threadsToRemove = null; List<ThreadWatchdogInfo> threadsToRemove = null;
const ThreadState thgone = ThreadState.Stopped | ThreadState.Aborted | ThreadState.AbortRequested;
lock (m_threads) lock (m_threads)
{ {
foreach(ThreadWatchdogInfo threadInfo in m_threads.Values) foreach(ThreadWatchdogInfo threadInfo in m_threads.Values)
{ {
if(threadInfo.Thread.ThreadState == ThreadState.Stopped) if(!m_enabled)
return;
if(!threadInfo.Thread.IsAlive || (threadInfo.Thread.ThreadState & thgone) != 0)
{ {
if(threadsToRemove == null) if(threadsToRemove == null)
threadsToRemove = new List<ThreadWatchdogInfo>(); threadsToRemove = new List<ThreadWatchdogInfo>();
threadsToRemove.Add(threadInfo); threadsToRemove.Add(threadInfo);
/*
if(callbackInfos == null) if(callbackInfos == null)
callbackInfos = new List<ThreadWatchdogInfo>(); callbackInfos = new List<ThreadWatchdogInfo>();
callbackInfos.Add(threadInfo); callbackInfos.Add(threadInfo);
*/
} }
else if(!threadInfo.IsTimedOut && now - threadInfo.LastTick >= threadInfo.Timeout) else if(!threadInfo.IsTimedOut && now - threadInfo.LastTick >= threadInfo.Timeout)
{ {

View File

@ -511,8 +511,6 @@ namespace OpenSim
private void WatchdogTimeoutHandler(Watchdog.ThreadWatchdogInfo twi) private void WatchdogTimeoutHandler(Watchdog.ThreadWatchdogInfo twi)
{ {
int now = Environment.TickCount & Int32.MaxValue; int now = Environment.TickCount & Int32.MaxValue;
if(twi.Thread.ThreadState == System.Threading.ThreadState.Stopped)
return;
m_log.ErrorFormat( m_log.ErrorFormat(
"[WATCHDOG]: Timeout detected for thread \"{0}\". ThreadState={1}. Last tick was {2}ms ago. {3}", "[WATCHDOG]: Timeout detected for thread \"{0}\". ThreadState={1}. Last tick was {2}ms ago. {3}",
twi.Thread.Name, twi.Thread.Name,