aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2011-10-25 20:49:46 +0100
committerJustin Clark-Casey (justincc)2011-10-25 20:49:46 +0100
commit968cae6c17fab8aa8a15bfd8231b50873aa6e794 (patch)
tree2c0f09c964f18a6b4a0977d9ac59afc84e556d9f /OpenSim
parentMake OpenSim.Framework.Servers.HttpServer rely on OpenSim.Framework instead o... (diff)
downloadopensim-SC_OLD-968cae6c17fab8aa8a15bfd8231b50873aa6e794.zip
opensim-SC_OLD-968cae6c17fab8aa8a15bfd8231b50873aa6e794.tar.gz
opensim-SC_OLD-968cae6c17fab8aa8a15bfd8231b50873aa6e794.tar.bz2
opensim-SC_OLD-968cae6c17fab8aa8a15bfd8231b50873aa6e794.tar.xz
Add "threads abort <thread-id>" simulator console command that allows us to abort a watchdog managed thread.
This is for diagnostic purposes.
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Framework/Servers/BaseOpenSimServer.cs25
-rw-r--r--OpenSim/Framework/Watchdog.cs25
2 files changed, 48 insertions, 2 deletions
diff --git a/OpenSim/Framework/Servers/BaseOpenSimServer.cs b/OpenSim/Framework/Servers/BaseOpenSimServer.cs
index 688be3f..b242e1c 100644
--- a/OpenSim/Framework/Servers/BaseOpenSimServer.cs
+++ b/OpenSim/Framework/Servers/BaseOpenSimServer.cs
@@ -192,6 +192,10 @@ namespace OpenSim.Framework.Servers
192 m_console.Commands.AddCommand("base", false, "show version", 192 m_console.Commands.AddCommand("base", false, "show version",
193 "show version", 193 "show version",
194 "Show server version", HandleShow); 194 "Show server version", HandleShow);
195
196 m_console.Commands.AddCommand("base", false, "threads abort",
197 "threads abort <thread-id>",
198 "Abort a managed thread. Use \"show threads\" to find possible threads.", HandleThreadsAbort);
195 } 199 }
196 } 200 }
197 201
@@ -395,6 +399,27 @@ namespace OpenSim.Framework.Servers
395 break; 399 break;
396 } 400 }
397 } 401 }
402
403 public virtual void HandleThreadsAbort(string module, string[] cmd)
404 {
405 if (cmd.Length != 3)
406 {
407 MainConsole.Instance.Output("Usage: threads abort <thread-id>");
408 return;
409 }
410
411 int threadId;
412 if (!int.TryParse(cmd[2], out threadId))
413 {
414 MainConsole.Instance.Output("ERROR: Thread id must be an integer");
415 return;
416 }
417
418 if (Watchdog.AbortThread(threadId))
419 MainConsole.Instance.OutputFormat("Aborted thread with id {0}", threadId);
420 else
421 MainConsole.Instance.OutputFormat("ERROR - Thread with id {0} not found in managed threads", threadId);
422 }
398 423
399 protected void ShowInfo() 424 protected void ShowInfo()
400 { 425 {
diff --git a/OpenSim/Framework/Watchdog.cs b/OpenSim/Framework/Watchdog.cs
index 0f34e83..c947ea6 100644
--- a/OpenSim/Framework/Watchdog.cs
+++ b/OpenSim/Framework/Watchdog.cs
@@ -112,8 +112,10 @@ namespace OpenSim.Framework
112 /// <summary> 112 /// <summary>
113 /// Stops watchdog tracking on the current thread 113 /// Stops watchdog tracking on the current thread
114 /// </summary> 114 /// </summary>
115 /// <returns>True if the thread was removed from the list of tracked 115 /// <returns>
116 /// threads, otherwise false</returns> 116 /// True if the thread was removed from the list of tracked
117 /// threads, otherwise false
118 /// </returns>
117 public static bool RemoveThread() 119 public static bool RemoveThread()
118 { 120 {
119 return RemoveThread(Thread.CurrentThread.ManagedThreadId); 121 return RemoveThread(Thread.CurrentThread.ManagedThreadId);
@@ -133,6 +135,25 @@ namespace OpenSim.Framework
133 return m_threads.Remove(threadID); 135 return m_threads.Remove(threadID);
134 } 136 }
135 137
138 public static bool AbortThread(int threadID)
139 {
140 lock (m_threads)
141 {
142 if (m_threads.ContainsKey(threadID))
143 {
144 ThreadWatchdogInfo twi = m_threads[threadID];
145 twi.Thread.Abort();
146 RemoveThread(threadID);
147
148 return true;
149 }
150 else
151 {
152 return false;
153 }
154 }
155 }
156
136 private static void UpdateThread(int threadID) 157 private static void UpdateThread(int threadID)
137 { 158 {
138 ThreadWatchdogInfo threadInfo; 159 ThreadWatchdogInfo threadInfo;