Fix "show threads" to show threads now being managed by OpenSim.Framework.Watchdog

This commit is contained in:
Justin Clark-Casey (justincc)
2010-09-14 22:24:11 +01:00
parent 095d400f5b
commit 609375bf37
2 changed files with 22 additions and 18 deletions

View File

@@ -37,6 +37,7 @@ using log4net;
using log4net.Appender;
using log4net.Core;
using log4net.Repository;
using OpenSim.Framework;
using OpenSim.Framework.Console;
using OpenSim.Framework.Servers;
using OpenSim.Framework.Servers.HttpServer;
@@ -234,26 +235,19 @@ namespace OpenSim.Framework.Servers
protected string GetThreadsReport()
{
StringBuilder sb = new StringBuilder();
Watchdog.ThreadWatchdogInfo[] threads = Watchdog.GetThreads();
ProcessThreadCollection threads = ThreadTracker.GetThreads();
if (threads == null)
sb.Append(threads.Length + " threads are being tracked:" + Environment.NewLine);
foreach (Watchdog.ThreadWatchdogInfo twi in threads)
{
sb.Append("OpenSim thread tracking is only enabled in DEBUG mode.");
Thread t = twi.Thread;
sb.Append(
"ID: " + t.ManagedThreadId + ", Name: " + t.Name + ", TimeRunning: "
+ "Pri: " + t.Priority + ", State: " + t.ThreadState);
sb.Append(Environment.NewLine);
}
else
{
sb.Append(threads.Count + " threads are being tracked:" + Environment.NewLine);
foreach (ProcessThread t in threads)
{
sb.Append("ID: " + t.Id + ", TotalProcessorTime: " + t.TotalProcessorTime + ", TimeRunning: " +
(DateTime.Now - t.StartTime) + ", Pri: " + t.CurrentPriority + ", State: " + t.ThreadState);
if (t.ThreadState == System.Diagnostics.ThreadState.Wait)
sb.Append(", Reason: " + t.WaitReason + Environment.NewLine);
else
sb.Append(Environment.NewLine);
}
}
int workers = 0, ports = 0, maxWorkers = 0, maxPorts = 0;
ThreadPool.GetAvailableThreads(out workers, out ports);
ThreadPool.GetMaxThreads(out maxWorkers, out maxPorts);