diff options
Merge branch 'ubitwork' of ssh://3dhosting.de/var/git/careminster into ubitwork
Diffstat (limited to 'OpenSim/Framework/Monitoring/Watchdog.cs')
-rw-r--r-- | OpenSim/Framework/Monitoring/Watchdog.cs | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/OpenSim/Framework/Monitoring/Watchdog.cs b/OpenSim/Framework/Monitoring/Watchdog.cs index b709baa..69d2db5 100644 --- a/OpenSim/Framework/Monitoring/Watchdog.cs +++ b/OpenSim/Framework/Monitoring/Watchdog.cs | |||
@@ -39,7 +39,7 @@ namespace OpenSim.Framework.Monitoring | |||
39 | public static class Watchdog | 39 | public static class Watchdog |
40 | { | 40 | { |
41 | /// <summary>Timer interval in milliseconds for the watchdog timer</summary> | 41 | /// <summary>Timer interval in milliseconds for the watchdog timer</summary> |
42 | const double WATCHDOG_INTERVAL_MS = 2500.0d; | 42 | public const double WATCHDOG_INTERVAL_MS = 2500.0d; |
43 | 43 | ||
44 | /// <summary>Default timeout in milliseconds before a thread is considered dead</summary> | 44 | /// <summary>Default timeout in milliseconds before a thread is considered dead</summary> |
45 | public const int DEFAULT_WATCHDOG_TIMEOUT_MS = 5000; | 45 | public const int DEFAULT_WATCHDOG_TIMEOUT_MS = 5000; |
@@ -89,6 +89,17 @@ namespace OpenSim.Framework.Monitoring | |||
89 | FirstTick = Environment.TickCount & Int32.MaxValue; | 89 | FirstTick = Environment.TickCount & Int32.MaxValue; |
90 | LastTick = FirstTick; | 90 | LastTick = FirstTick; |
91 | } | 91 | } |
92 | |||
93 | public ThreadWatchdogInfo(ThreadWatchdogInfo previousTwi) | ||
94 | { | ||
95 | Thread = previousTwi.Thread; | ||
96 | FirstTick = previousTwi.FirstTick; | ||
97 | LastTick = previousTwi.LastTick; | ||
98 | Timeout = previousTwi.Timeout; | ||
99 | IsTimedOut = previousTwi.IsTimedOut; | ||
100 | AlarmIfTimeout = previousTwi.AlarmIfTimeout; | ||
101 | AlarmMethod = previousTwi.AlarmMethod; | ||
102 | } | ||
92 | } | 103 | } |
93 | 104 | ||
94 | /// <summary> | 105 | /// <summary> |
@@ -220,7 +231,25 @@ namespace OpenSim.Framework.Monitoring | |||
220 | private static bool RemoveThread(int threadID) | 231 | private static bool RemoveThread(int threadID) |
221 | { | 232 | { |
222 | lock (m_threads) | 233 | lock (m_threads) |
223 | return m_threads.Remove(threadID); | 234 | { |
235 | ThreadWatchdogInfo twi; | ||
236 | if (m_threads.TryGetValue(threadID, out twi)) | ||
237 | { | ||
238 | m_log.DebugFormat( | ||
239 | "[WATCHDOG]: Removing thread {0}, ID {1}", twi.Thread.Name, twi.Thread.ManagedThreadId); | ||
240 | |||
241 | m_threads.Remove(threadID); | ||
242 | |||
243 | return true; | ||
244 | } | ||
245 | else | ||
246 | { | ||
247 | m_log.WarnFormat( | ||
248 | "[WATCHDOG]: Requested to remove thread with ID {0} but this is not being monitored", threadID); | ||
249 | |||
250 | return false; | ||
251 | } | ||
252 | } | ||
224 | } | 253 | } |
225 | 254 | ||
226 | public static bool AbortThread(int threadID) | 255 | public static bool AbortThread(int threadID) |
@@ -335,7 +364,9 @@ namespace OpenSim.Framework.Monitoring | |||
335 | if (callbackInfos == null) | 364 | if (callbackInfos == null) |
336 | callbackInfos = new List<ThreadWatchdogInfo>(); | 365 | callbackInfos = new List<ThreadWatchdogInfo>(); |
337 | 366 | ||
338 | callbackInfos.Add(threadInfo); | 367 | // Send a copy of the watchdog info to prevent race conditions where the watchdog |
368 | // thread updates the monitoring info after an alarm has been sent out. | ||
369 | callbackInfos.Add(new ThreadWatchdogInfo(threadInfo)); | ||
339 | } | 370 | } |
340 | } | 371 | } |
341 | } | 372 | } |
@@ -349,6 +380,8 @@ namespace OpenSim.Framework.Monitoring | |||
349 | if (MemoryWatchdog.Enabled) | 380 | if (MemoryWatchdog.Enabled) |
350 | MemoryWatchdog.Update(); | 381 | MemoryWatchdog.Update(); |
351 | 382 | ||
383 | StatsManager.RecordStats(); | ||
384 | |||
352 | m_watchdogTimer.Start(); | 385 | m_watchdogTimer.Start(); |
353 | } | 386 | } |
354 | } | 387 | } |