diff options
author | Melanie | 2012-06-07 23:33:40 +0100 |
---|---|---|
committer | Melanie | 2012-06-07 23:33:40 +0100 |
commit | e8cd9fbbb748aed1caac4a5d20d7e723351349dd (patch) | |
tree | b901dfb2ebf4237a77aeebf1fbb929456a615693 /OpenSim/Framework/Watchdog.cs | |
parent | Remove a null ref when an avatar's attachment gets the avatar velocity (diff) | |
parent | Record the fact that child agents can have asset transactions. (diff) | |
download | opensim-SC-e8cd9fbbb748aed1caac4a5d20d7e723351349dd.zip opensim-SC-e8cd9fbbb748aed1caac4a5d20d7e723351349dd.tar.gz opensim-SC-e8cd9fbbb748aed1caac4a5d20d7e723351349dd.tar.bz2 opensim-SC-e8cd9fbbb748aed1caac4a5d20d7e723351349dd.tar.xz |
Merge branch 'master' into careminster
Conflicts:
OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
Diffstat (limited to 'OpenSim/Framework/Watchdog.cs')
-rw-r--r-- | OpenSim/Framework/Watchdog.cs | 40 |
1 files changed, 23 insertions, 17 deletions
diff --git a/OpenSim/Framework/Watchdog.cs b/OpenSim/Framework/Watchdog.cs index 881b6aa..68bf477 100644 --- a/OpenSim/Framework/Watchdog.cs +++ b/OpenSim/Framework/Watchdog.cs | |||
@@ -42,7 +42,7 @@ namespace OpenSim.Framework | |||
42 | const double WATCHDOG_INTERVAL_MS = 2500.0d; | 42 | const double WATCHDOG_INTERVAL_MS = 2500.0d; |
43 | 43 | ||
44 | /// <summary>Maximum timeout in milliseconds before a thread is considered dead</summary> | 44 | /// <summary>Maximum timeout in milliseconds before a thread is considered dead</summary> |
45 | const int WATCHDOG_TIMEOUT_MS = 5000; | 45 | public const int WATCHDOG_TIMEOUT_MS = 5000; |
46 | 46 | ||
47 | [System.Diagnostics.DebuggerDisplay("{Thread.Name}")] | 47 | [System.Diagnostics.DebuggerDisplay("{Thread.Name}")] |
48 | public class ThreadWatchdogInfo | 48 | public class ThreadWatchdogInfo |
@@ -58,7 +58,7 @@ namespace OpenSim.Framework | |||
58 | public int FirstTick { get; private set; } | 58 | public int FirstTick { get; private set; } |
59 | 59 | ||
60 | /// <summary> | 60 | /// <summary> |
61 | /// First time this heartbeat update was invoked | 61 | /// Last time this heartbeat update was invoked |
62 | /// </summary> | 62 | /// </summary> |
63 | public int LastTick { get; set; } | 63 | public int LastTick { get; set; } |
64 | 64 | ||
@@ -77,6 +77,11 @@ namespace OpenSim.Framework | |||
77 | /// </summary> | 77 | /// </summary> |
78 | public bool AlarmIfTimeout { get; set; } | 78 | public bool AlarmIfTimeout { get; set; } |
79 | 79 | ||
80 | /// <summary> | ||
81 | /// Method execute if alarm goes off. If null then no alarm method is fired. | ||
82 | /// </summary> | ||
83 | public Func<string> AlarmMethod { get; set; } | ||
84 | |||
80 | public ThreadWatchdogInfo(Thread thread, int timeout) | 85 | public ThreadWatchdogInfo(Thread thread, int timeout) |
81 | { | 86 | { |
82 | Thread = thread; | 87 | Thread = thread; |
@@ -87,16 +92,10 @@ namespace OpenSim.Framework | |||
87 | } | 92 | } |
88 | 93 | ||
89 | /// <summary> | 94 | /// <summary> |
90 | /// This event is called whenever a tracked thread is stopped or | 95 | /// This event is called whenever a tracked thread is |
91 | /// has not called UpdateThread() in time | 96 | /// stopped or has not called UpdateThread() in time< |
92 | /// </summary> | 97 | /// /summary> |
93 | /// <param name="thread">The thread that has been identified as dead</param> | 98 | public static event Action<ThreadWatchdogInfo> OnWatchdogTimeout; |
94 | /// <param name="lastTick">The last time this thread called UpdateThread()</param> | ||
95 | public delegate void WatchdogTimeout(Thread thread, int lastTick); | ||
96 | |||
97 | /// <summary>This event is called whenever a tracked thread is | ||
98 | /// stopped or has not called UpdateThread() in time</summary> | ||
99 | public static event WatchdogTimeout OnWatchdogTimeout; | ||
100 | 99 | ||
101 | private static readonly ILog m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | 100 | private static readonly ILog m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); |
102 | private static Dictionary<int, ThreadWatchdogInfo> m_threads; | 101 | private static Dictionary<int, ThreadWatchdogInfo> m_threads; |
@@ -123,7 +122,7 @@ namespace OpenSim.Framework | |||
123 | public static Thread StartThread( | 122 | public static Thread StartThread( |
124 | ThreadStart start, string name, ThreadPriority priority, bool isBackground, bool alarmIfTimeout) | 123 | ThreadStart start, string name, ThreadPriority priority, bool isBackground, bool alarmIfTimeout) |
125 | { | 124 | { |
126 | return StartThread(start, name, priority, isBackground, alarmIfTimeout, WATCHDOG_TIMEOUT_MS); | 125 | return StartThread(start, name, priority, isBackground, alarmIfTimeout, null, WATCHDOG_TIMEOUT_MS); |
127 | } | 126 | } |
128 | 127 | ||
129 | /// <summary> | 128 | /// <summary> |
@@ -135,17 +134,24 @@ namespace OpenSim.Framework | |||
135 | /// <param name="isBackground">True to run this thread as a background | 134 | /// <param name="isBackground">True to run this thread as a background |
136 | /// thread, otherwise false</param> | 135 | /// thread, otherwise false</param> |
137 | /// <param name="alarmIfTimeout">Trigger an alarm function is we have timed out</param> | 136 | /// <param name="alarmIfTimeout">Trigger an alarm function is we have timed out</param> |
137 | /// <param name="alarmMethod"> | ||
138 | /// Alarm method to call if alarmIfTimeout is true and there is a timeout. | ||
139 | /// Normally, this will just return some useful debugging information. | ||
140 | /// </param> | ||
138 | /// <param name="timeout">Number of milliseconds to wait until we issue a warning about timeout.</param> | 141 | /// <param name="timeout">Number of milliseconds to wait until we issue a warning about timeout.</param> |
139 | /// <returns>The newly created Thread object</returns> | 142 | /// <returns>The newly created Thread object</returns> |
140 | public static Thread StartThread( | 143 | public static Thread StartThread( |
141 | ThreadStart start, string name, ThreadPriority priority, bool isBackground, bool alarmIfTimeout, int timeout) | 144 | ThreadStart start, string name, ThreadPriority priority, bool isBackground, |
145 | bool alarmIfTimeout, Func<string> alarmMethod, int timeout) | ||
142 | { | 146 | { |
143 | Thread thread = new Thread(start); | 147 | Thread thread = new Thread(start); |
144 | thread.Name = name; | 148 | thread.Name = name; |
145 | thread.Priority = priority; | 149 | thread.Priority = priority; |
146 | thread.IsBackground = isBackground; | 150 | thread.IsBackground = isBackground; |
147 | 151 | ||
148 | ThreadWatchdogInfo twi = new ThreadWatchdogInfo(thread, timeout) { AlarmIfTimeout = alarmIfTimeout }; | 152 | ThreadWatchdogInfo twi |
153 | = new ThreadWatchdogInfo(thread, timeout) | ||
154 | { AlarmIfTimeout = alarmIfTimeout, AlarmMethod = alarmMethod }; | ||
149 | 155 | ||
150 | m_log.DebugFormat( | 156 | m_log.DebugFormat( |
151 | "[WATCHDOG]: Started tracking thread {0}, ID {1}", twi.Thread.Name, twi.Thread.ManagedThreadId); | 157 | "[WATCHDOG]: Started tracking thread {0}, ID {1}", twi.Thread.Name, twi.Thread.ManagedThreadId); |
@@ -258,7 +264,7 @@ namespace OpenSim.Framework | |||
258 | /// <param name="e"></param> | 264 | /// <param name="e"></param> |
259 | private static void WatchdogTimerElapsed(object sender, System.Timers.ElapsedEventArgs e) | 265 | private static void WatchdogTimerElapsed(object sender, System.Timers.ElapsedEventArgs e) |
260 | { | 266 | { |
261 | WatchdogTimeout callback = OnWatchdogTimeout; | 267 | Action<ThreadWatchdogInfo> callback = OnWatchdogTimeout; |
262 | 268 | ||
263 | if (callback != null) | 269 | if (callback != null) |
264 | { | 270 | { |
@@ -296,7 +302,7 @@ namespace OpenSim.Framework | |||
296 | 302 | ||
297 | if (callbackInfos != null) | 303 | if (callbackInfos != null) |
298 | foreach (ThreadWatchdogInfo callbackInfo in callbackInfos) | 304 | foreach (ThreadWatchdogInfo callbackInfo in callbackInfos) |
299 | callback(callbackInfo.Thread, callbackInfo.LastTick); | 305 | callback(callbackInfo); |
300 | } | 306 | } |
301 | 307 | ||
302 | m_watchdogTimer.Start(); | 308 | m_watchdogTimer.Start(); |