aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/ThreadTracker.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/ThreadTracker.cs36
1 files changed, 24 insertions, 12 deletions
diff --git a/OpenSim/Framework/ThreadTracker.cs b/OpenSim/Framework/ThreadTracker.cs
index d8bd2c0..fa6f0b8 100644
--- a/OpenSim/Framework/ThreadTracker.cs
+++ b/OpenSim/Framework/ThreadTracker.cs
@@ -77,12 +77,15 @@ namespace OpenSim.Framework
77 public static void Add(Thread thread) 77 public static void Add(Thread thread)
78 { 78 {
79#if DEBUG 79#if DEBUG
80 lock (m_Threads) 80 if (thread != null)
81 { 81 {
82 ThreadTrackerItem tti = new ThreadTrackerItem(); 82 lock (m_Threads)
83 tti.Thread = thread; 83 {
84 tti.LastSeenActive = DateTime.Now.Ticks; 84 ThreadTrackerItem tti = new ThreadTrackerItem();
85 m_Threads.Add(tti); 85 tti.Thread = thread;
86 tti.LastSeenActive = DateTime.Now.Ticks;
87 m_Threads.Add(tti);
88 }
86 } 89 }
87#endif 90#endif
88 } 91 }
@@ -107,16 +110,25 @@ namespace OpenSim.Framework
107 { 110 {
108 foreach (ThreadTrackerItem tti in new ArrayList(m_Threads)) 111 foreach (ThreadTrackerItem tti in new ArrayList(m_Threads))
109 { 112 {
110 if (tti.Thread.IsAlive) 113 try
111 { 114 {
112 // Its active 115
113 tti.LastSeenActive = DateTime.Now.Ticks; 116
117 if (tti.Thread.IsAlive)
118 {
119 // Its active
120 tti.LastSeenActive = DateTime.Now.Ticks;
121 }
122 else
123 {
124 // Its not active -- if its expired then remove it
125 if (tti.LastSeenActive + ThreadTimeout < DateTime.Now.Ticks)
126 m_Threads.Remove(tti);
127 }
114 } 128 }
115 else 129 catch (NullReferenceException)
116 { 130 {
117 // Its not active -- if its expired then remove it 131 m_Threads.Remove(tti);
118 if (tti.LastSeenActive + ThreadTimeout < DateTime.Now.Ticks)
119 m_Threads.Remove(tti);
120 } 132 }
121 } 133 }
122 } 134 }