aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2012-07-05 23:15:59 +0100
committerJustin Clark-Casey (justincc)2012-07-05 23:15:59 +0100
commit7e73f609e5f61040358ec247d371306165945ca1 (patch)
tree93f38bac65a2021a1438f4f47eb07cbebae0c99c /OpenSim
parentminor: add client name to various login service log messages to disambiguate ... (diff)
downloadopensim-SC-7e73f609e5f61040358ec247d371306165945ca1.zip
opensim-SC-7e73f609e5f61040358ec247d371306165945ca1.tar.gz
opensim-SC-7e73f609e5f61040358ec247d371306165945ca1.tar.bz2
opensim-SC-7e73f609e5f61040358ec247d371306165945ca1.tar.xz
Log warning if time between invocations of the watchdog thread is twice 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.
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/Watchdog.cs24
1 files changed, 22 insertions, 2 deletions
diff --git a/OpenSim/Framework/Watchdog.cs b/OpenSim/Framework/Watchdog.cs
index 2b3a719..8a74f53 100644
--- a/OpenSim/Framework/Watchdog.cs
+++ b/OpenSim/Framework/Watchdog.cs
@@ -101,12 +101,24 @@ namespace OpenSim.Framework
101 private static Dictionary<int, ThreadWatchdogInfo> m_threads; 101 private static Dictionary<int, ThreadWatchdogInfo> m_threads;
102 private static System.Timers.Timer m_watchdogTimer; 102 private static System.Timers.Timer m_watchdogTimer;
103 103
104 /// <summary>
105 /// Last time the watchdog thread ran.
106 /// </summary>
107 /// <remarks>
108 /// Should run every WATCHDOG_INTERVAL_MS
109 /// </remarks>
110 public static int LastWatchdogThreadTick { get; private set; }
111
104 static Watchdog() 112 static Watchdog()
105 { 113 {
106 m_threads = new Dictionary<int, ThreadWatchdogInfo>(); 114 m_threads = new Dictionary<int, ThreadWatchdogInfo>();
107 m_watchdogTimer = new System.Timers.Timer(WATCHDOG_INTERVAL_MS); 115 m_watchdogTimer = new System.Timers.Timer(WATCHDOG_INTERVAL_MS);
108 m_watchdogTimer.AutoReset = false; 116 m_watchdogTimer.AutoReset = false;
109 m_watchdogTimer.Elapsed += WatchdogTimerElapsed; 117 m_watchdogTimer.Elapsed += WatchdogTimerElapsed;
118
119 // Set now so we don't get alerted on the first run
120 LastWatchdogThreadTick = Environment.TickCount & Int32.MaxValue;
121
110 m_watchdogTimer.Start(); 122 m_watchdogTimer.Start();
111 } 123 }
112 124
@@ -264,6 +276,16 @@ namespace OpenSim.Framework
264 /// <param name="e"></param> 276 /// <param name="e"></param>
265 private static void WatchdogTimerElapsed(object sender, System.Timers.ElapsedEventArgs e) 277 private static void WatchdogTimerElapsed(object sender, System.Timers.ElapsedEventArgs e)
266 { 278 {
279 int now = Environment.TickCount & Int32.MaxValue;
280 int msElapsed = now - LastWatchdogThreadTick;
281
282 if (msElapsed > WATCHDOG_INTERVAL_MS * 2)
283 m_log.WarnFormat(
284 "[WATCHDOG]: {0} ms since Watchdog last ran. Interval should be approximately {1} ms",
285 msElapsed, WATCHDOG_INTERVAL_MS);
286
287 LastWatchdogThreadTick = Environment.TickCount & Int32.MaxValue;
288
267 Action<ThreadWatchdogInfo> callback = OnWatchdogTimeout; 289 Action<ThreadWatchdogInfo> callback = OnWatchdogTimeout;
268 290
269 if (callback != null) 291 if (callback != null)
@@ -272,8 +294,6 @@ namespace OpenSim.Framework
272 294
273 lock (m_threads) 295 lock (m_threads)
274 { 296 {
275 int now = Environment.TickCount & Int32.MaxValue;
276
277 foreach (ThreadWatchdogInfo threadInfo in m_threads.Values) 297 foreach (ThreadWatchdogInfo threadInfo in m_threads.Values)
278 { 298 {
279 if (threadInfo.Thread.ThreadState == ThreadState.Stopped) 299 if (threadInfo.Thread.ThreadState == ThreadState.Stopped)