Add "threads abort <thread-id>" simulator console command that allows us to abort a watchdog managed thread.
This is for diagnostic purposes.remove-scene-viewer
parent
8a0a78cbcc
commit
968cae6c17
|
@ -192,6 +192,10 @@ namespace OpenSim.Framework.Servers
|
|||
m_console.Commands.AddCommand("base", false, "show version",
|
||||
"show version",
|
||||
"Show server version", HandleShow);
|
||||
|
||||
m_console.Commands.AddCommand("base", false, "threads abort",
|
||||
"threads abort <thread-id>",
|
||||
"Abort a managed thread. Use \"show threads\" to find possible threads.", HandleThreadsAbort);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -396,6 +400,27 @@ namespace OpenSim.Framework.Servers
|
|||
}
|
||||
}
|
||||
|
||||
public virtual void HandleThreadsAbort(string module, string[] cmd)
|
||||
{
|
||||
if (cmd.Length != 3)
|
||||
{
|
||||
MainConsole.Instance.Output("Usage: threads abort <thread-id>");
|
||||
return;
|
||||
}
|
||||
|
||||
int threadId;
|
||||
if (!int.TryParse(cmd[2], out threadId))
|
||||
{
|
||||
MainConsole.Instance.Output("ERROR: Thread id must be an integer");
|
||||
return;
|
||||
}
|
||||
|
||||
if (Watchdog.AbortThread(threadId))
|
||||
MainConsole.Instance.OutputFormat("Aborted thread with id {0}", threadId);
|
||||
else
|
||||
MainConsole.Instance.OutputFormat("ERROR - Thread with id {0} not found in managed threads", threadId);
|
||||
}
|
||||
|
||||
protected void ShowInfo()
|
||||
{
|
||||
Notice(GetVersionText());
|
||||
|
|
|
@ -112,8 +112,10 @@ namespace OpenSim.Framework
|
|||
/// <summary>
|
||||
/// Stops watchdog tracking on the current thread
|
||||
/// </summary>
|
||||
/// <returns>True if the thread was removed from the list of tracked
|
||||
/// threads, otherwise false</returns>
|
||||
/// <returns>
|
||||
/// True if the thread was removed from the list of tracked
|
||||
/// threads, otherwise false
|
||||
/// </returns>
|
||||
public static bool RemoveThread()
|
||||
{
|
||||
return RemoveThread(Thread.CurrentThread.ManagedThreadId);
|
||||
|
@ -133,6 +135,25 @@ namespace OpenSim.Framework
|
|||
return m_threads.Remove(threadID);
|
||||
}
|
||||
|
||||
public static bool AbortThread(int threadID)
|
||||
{
|
||||
lock (m_threads)
|
||||
{
|
||||
if (m_threads.ContainsKey(threadID))
|
||||
{
|
||||
ThreadWatchdogInfo twi = m_threads[threadID];
|
||||
twi.Thread.Abort();
|
||||
RemoveThread(threadID);
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void UpdateThread(int threadID)
|
||||
{
|
||||
ThreadWatchdogInfo threadInfo;
|
||||
|
|
Loading…
Reference in New Issue