Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Log warning if time between invocations of the watchdog thread is twi…

…ce the timer setting.

This is to help detect situations where thread timeout warnings are being generated because of general machine issues rather than deadlock, network or other problems.
  • Loading branch information...
commit 7e73f609e5f61040358ec247d371306165945ca1 1 parent db9616f
Justin Clark-Casey justincc authored
Showing with 22 additions and 2 deletions.
  1. +22 −2 OpenSim/Framework/Watchdog.cs
24 OpenSim/Framework/Watchdog.cs
View
@@ -101,12 +101,24 @@ public ThreadWatchdogInfo(Thread thread, int timeout)
private static Dictionary<int, ThreadWatchdogInfo> m_threads;
private static System.Timers.Timer m_watchdogTimer;
+ /// <summary>
+ /// Last time the watchdog thread ran.
+ /// </summary>
+ /// <remarks>
+ /// Should run every WATCHDOG_INTERVAL_MS
+ /// </remarks>
+ public static int LastWatchdogThreadTick { get; private set; }
+
static Watchdog()
{
m_threads = new Dictionary<int, ThreadWatchdogInfo>();
m_watchdogTimer = new System.Timers.Timer(WATCHDOG_INTERVAL_MS);
m_watchdogTimer.AutoReset = false;
m_watchdogTimer.Elapsed += WatchdogTimerElapsed;
+
+ // Set now so we don't get alerted on the first run
+ LastWatchdogThreadTick = Environment.TickCount & Int32.MaxValue;
+
m_watchdogTimer.Start();
}
@@ -264,6 +276,16 @@ public static ThreadWatchdogInfo GetCurrentThreadInfo()
/// <param name="e"></param>
private static void WatchdogTimerElapsed(object sender, System.Timers.ElapsedEventArgs e)
{
+ int now = Environment.TickCount & Int32.MaxValue;
+ int msElapsed = now - LastWatchdogThreadTick;
+
+ if (msElapsed > WATCHDOG_INTERVAL_MS * 2)
+ m_log.WarnFormat(
+ "[WATCHDOG]: {0} ms since Watchdog last ran. Interval should be approximately {1} ms",
+ msElapsed, WATCHDOG_INTERVAL_MS);
+
+ LastWatchdogThreadTick = Environment.TickCount & Int32.MaxValue;
+
Action<ThreadWatchdogInfo> callback = OnWatchdogTimeout;
if (callback != null)
@@ -272,8 +294,6 @@ private static void WatchdogTimerElapsed(object sender, System.Timers.ElapsedEve
lock (m_threads)
{
- int now = Environment.TickCount & Int32.MaxValue;
-
foreach (ThreadWatchdogInfo threadInfo in m_threads.Values)
{
if (threadInfo.Thread.ThreadState == ThreadState.Stopped)
Please sign in to comment.
Something went wrong with that request. Please try again.