diff options
author | Justin Clark-Casey (justincc) | 2012-02-24 05:25:18 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2012-02-24 05:25:18 +0000 |
commit | bafef292f4d41df14a1edeafc7ba5f9d623d7822 (patch) | |
tree | fafe03e1890e915c0d8d7375dc4188f434fb37db /OpenSim/Framework/Watchdog.cs | |
parent | Rename Watchdog.GetThreads() to GetThreadsInfo() to reflect what it actually ... (diff) | |
download | opensim-SC-bafef292f4d41df14a1edeafc7ba5f9d623d7822.zip opensim-SC-bafef292f4d41df14a1edeafc7ba5f9d623d7822.tar.gz opensim-SC-bafef292f4d41df14a1edeafc7ba5f9d623d7822.tar.bz2 opensim-SC-bafef292f4d41df14a1edeafc7ba5f9d623d7822.tar.xz |
Take watchdog alarm calling back outside the m_threads lock.
This is how it was originally. This stops a very long running alarm callback from causing a problem.
Diffstat (limited to 'OpenSim/Framework/Watchdog.cs')
-rw-r--r-- | OpenSim/Framework/Watchdog.cs | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/OpenSim/Framework/Watchdog.cs b/OpenSim/Framework/Watchdog.cs index 4891a66..e93e50e 100644 --- a/OpenSim/Framework/Watchdog.cs +++ b/OpenSim/Framework/Watchdog.cs | |||
@@ -262,7 +262,7 @@ namespace OpenSim.Framework | |||
262 | 262 | ||
263 | if (callback != null) | 263 | if (callback != null) |
264 | { | 264 | { |
265 | ThreadWatchdogInfo timedOut = null; | 265 | List<ThreadWatchdogInfo> callbackInfos = null; |
266 | 266 | ||
267 | lock (m_threads) | 267 | lock (m_threads) |
268 | { | 268 | { |
@@ -273,17 +273,30 @@ namespace OpenSim.Framework | |||
273 | if (threadInfo.Thread.ThreadState == ThreadState.Stopped) | 273 | if (threadInfo.Thread.ThreadState == ThreadState.Stopped) |
274 | { | 274 | { |
275 | RemoveThread(threadInfo.Thread.ManagedThreadId); | 275 | RemoveThread(threadInfo.Thread.ManagedThreadId); |
276 | callback(threadInfo.Thread, threadInfo.LastTick); | 276 | |
277 | if (callbackInfos == null) | ||
278 | callbackInfos = new List<ThreadWatchdogInfo>(); | ||
279 | |||
280 | callbackInfos.Add(threadInfo); | ||
277 | } | 281 | } |
278 | else if (!threadInfo.IsTimedOut && now - threadInfo.LastTick >= threadInfo.Timeout) | 282 | else if (!threadInfo.IsTimedOut && now - threadInfo.LastTick >= threadInfo.Timeout) |
279 | { | 283 | { |
280 | threadInfo.IsTimedOut = true; | 284 | threadInfo.IsTimedOut = true; |
281 | 285 | ||
282 | if (threadInfo.AlarmIfTimeout) | 286 | if (threadInfo.AlarmIfTimeout) |
283 | callback(threadInfo.Thread, threadInfo.LastTick); | 287 | { |
288 | if (callbackInfos == null) | ||
289 | callbackInfos = new List<ThreadWatchdogInfo>(); | ||
290 | |||
291 | callbackInfos.Add(threadInfo); | ||
292 | } | ||
284 | } | 293 | } |
285 | } | 294 | } |
286 | } | 295 | } |
296 | |||
297 | if (callbackInfos != null) | ||
298 | foreach (ThreadWatchdogInfo callbackInfo in callbackInfos) | ||
299 | callback(callbackInfo.Thread, callbackInfo.LastTick); | ||
287 | } | 300 | } |
288 | 301 | ||
289 | m_watchdogTimer.Start(); | 302 | m_watchdogTimer.Start(); |