"threads" command now works. I've added manual tracking of threads (only if compiled in DEBUG mode)... Its ugly and even requires a separate thread to track the treads, but it will be very valuable in debugging.
parent
4a621d106c
commit
7102ac7769
|
@ -171,6 +171,7 @@ namespace OpenSim.Framework.Communications.Cache
|
||||||
m_assetCacheThread.Name = "AssetCacheThread";
|
m_assetCacheThread.Name = "AssetCacheThread";
|
||||||
m_assetCacheThread.IsBackground = true;
|
m_assetCacheThread.IsBackground = true;
|
||||||
m_assetCacheThread.Start();
|
m_assetCacheThread.Start();
|
||||||
|
OpenSim.Framework.ThreadTracker.Add(m_assetCacheThread);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -101,6 +101,7 @@ namespace OpenSim.Framework.Communications.Cache
|
||||||
m_localAssetServerThread.Name = "LocalAssetServerThread";
|
m_localAssetServerThread.Name = "LocalAssetServerThread";
|
||||||
m_localAssetServerThread.IsBackground = true;
|
m_localAssetServerThread.IsBackground = true;
|
||||||
m_localAssetServerThread.Start();
|
m_localAssetServerThread.Start();
|
||||||
|
OpenSim.Framework.ThreadTracker.Add(m_localAssetServerThread);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RunRequests()
|
private void RunRequests()
|
||||||
|
|
|
@ -550,6 +550,7 @@ namespace OpenSim.Framework.Servers
|
||||||
m_workerThread.Name = "HttpThread";
|
m_workerThread.Name = "HttpThread";
|
||||||
m_workerThread.IsBackground = true;
|
m_workerThread.IsBackground = true;
|
||||||
m_workerThread.Start();
|
m_workerThread.Start();
|
||||||
|
OpenSim.Framework.ThreadTracker.Add(m_workerThread);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void StartHTTP()
|
private void StartHTTP()
|
||||||
|
|
|
@ -0,0 +1,106 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework
|
||||||
|
{
|
||||||
|
public static class ThreadTracker
|
||||||
|
{
|
||||||
|
public static List<ThreadTrackerItem> m_Threads;
|
||||||
|
public static System.Threading.Thread ThreadTrackerThread;
|
||||||
|
private static readonly long ThreadTimeout = 30 * 10000000;
|
||||||
|
|
||||||
|
static ThreadTracker()
|
||||||
|
{
|
||||||
|
#if DEBUG
|
||||||
|
m_Threads = new List<ThreadTrackerItem>();
|
||||||
|
ThreadTrackerThread = new Thread(ThreadTrackerThreadLoop);
|
||||||
|
ThreadTrackerThread.Name = "ThreadTrackerThread";
|
||||||
|
ThreadTrackerThread.IsBackground = true;
|
||||||
|
ThreadTrackerThread.Priority = System.Threading.ThreadPriority.BelowNormal;
|
||||||
|
ThreadTrackerThread.Start();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void ThreadTrackerThreadLoop()
|
||||||
|
{
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
Thread.Sleep(5000);
|
||||||
|
CleanUp();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Add(System.Threading.Thread thread)
|
||||||
|
{
|
||||||
|
#if DEBUG
|
||||||
|
lock (m_Threads)
|
||||||
|
{
|
||||||
|
ThreadTrackerItem tti = new ThreadTrackerItem();
|
||||||
|
tti.Thread = thread;
|
||||||
|
tti.LastSeenActive = DateTime.Now.Ticks;
|
||||||
|
m_Threads.Add(tti);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Remove(System.Threading.Thread thread)
|
||||||
|
{
|
||||||
|
#if DEBUG
|
||||||
|
lock (m_Threads)
|
||||||
|
{
|
||||||
|
foreach (ThreadTrackerItem tti in new ArrayList(m_Threads))
|
||||||
|
{
|
||||||
|
if (tti.Thread == thread)
|
||||||
|
m_Threads.Remove(tti);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void CleanUp()
|
||||||
|
{
|
||||||
|
lock (m_Threads)
|
||||||
|
{
|
||||||
|
foreach (ThreadTrackerItem tti in new ArrayList(m_Threads))
|
||||||
|
{
|
||||||
|
if (tti.Thread.IsAlive)
|
||||||
|
{
|
||||||
|
// Its active
|
||||||
|
tti.LastSeenActive = DateTime.Now.Ticks;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Its not active -- if its expired then remove it
|
||||||
|
if (tti.LastSeenActive + ThreadTimeout < DateTime.Now.Ticks)
|
||||||
|
m_Threads.Remove(tti);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<Thread> GetThreads()
|
||||||
|
{
|
||||||
|
if (m_Threads == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
List<Thread> threads = new List<Thread>();
|
||||||
|
lock (m_Threads)
|
||||||
|
{
|
||||||
|
foreach (ThreadTrackerItem tti in new ArrayList(m_Threads))
|
||||||
|
{
|
||||||
|
threads.Add(tti.Thread);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return threads;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ThreadTrackerItem
|
||||||
|
{
|
||||||
|
public System.Threading.Thread Thread;
|
||||||
|
public long LastSeenActive;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -61,6 +61,7 @@ namespace OpenSim.Grid.ScriptServer
|
||||||
listenThread.Name = "ListenThread";
|
listenThread.Name = "ListenThread";
|
||||||
listenThread.IsBackground = true;
|
listenThread.IsBackground = true;
|
||||||
listenThread.Start();
|
listenThread.Start();
|
||||||
|
OpenSim.Framework.ThreadTracker.Add(listenThread);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -754,15 +754,30 @@ namespace OpenSim
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "threads":
|
case "threads":
|
||||||
m_console.Notice("THREAD", Process.GetCurrentProcess().Threads.Count + " threads running:");
|
//m_console.Notice("THREAD", Process.GetCurrentProcess().Threads.Count + " threads running:");
|
||||||
int _tc = 0;
|
//int _tc = 0;
|
||||||
|
|
||||||
foreach (ProcessThread pt in Process.GetCurrentProcess().Threads)
|
//foreach (ProcessThread pt in Process.GetCurrentProcess().Threads)
|
||||||
|
//{
|
||||||
|
// _tc++;
|
||||||
|
// m_console.Notice("THREAD", _tc + ": ID: " + pt.Id + ", Started: " + pt.StartTime.ToString() + ", CPU time: " + pt.TotalProcessorTime + ", Pri: " + pt.BasePriority.ToString() + ", State: " + pt.ThreadState.ToString());
|
||||||
|
|
||||||
|
//}
|
||||||
|
List<Thread> threads = OpenSim.Framework.ThreadTracker.GetThreads();
|
||||||
|
if (threads == null)
|
||||||
|
{
|
||||||
|
m_console.Notice("THREAD", "Thread tracking is only enabled in DEBUG mode.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int _tc = 0;
|
||||||
|
m_console.Notice("THREAD", threads.Count + " threads are being tracked:");
|
||||||
|
foreach (Thread t in threads)
|
||||||
{
|
{
|
||||||
_tc++;
|
_tc++;
|
||||||
m_console.Notice("THREAD", _tc + ": ID: " + pt.Id + ", Started: " + pt.StartTime.ToString() + ", CPU time: " + pt.TotalProcessorTime + ", Pri: " + pt.BasePriority.ToString() + ", State: " + pt.ThreadState.ToString());
|
m_console.Notice("THREAD", _tc + ": ID: " + t.ManagedThreadId.ToString() + ", Name: " + t.Name + ", Alive: " + t.IsAlive.ToString() + ", Pri: " + t.Priority.ToString() + ", State: " + t.ThreadState.ToString());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -228,6 +228,7 @@ namespace OpenSim.Region.ClientStack
|
||||||
m_clientThread.Name = "ClientThread";
|
m_clientThread.Name = "ClientThread";
|
||||||
m_clientThread.IsBackground = true;
|
m_clientThread.IsBackground = true;
|
||||||
m_clientThread.Start();
|
m_clientThread.Start();
|
||||||
|
OpenSim.Framework.ThreadTracker.Add(m_clientThread);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetDebug(int newDebug)
|
public void SetDebug(int newDebug)
|
||||||
|
|
|
@ -113,7 +113,10 @@ namespace OpenSim.Region.Environment.Modules
|
||||||
m_irc_connector.Name = "IRCConnectorThread";
|
m_irc_connector.Name = "IRCConnectorThread";
|
||||||
m_irc_connector.IsBackground = true;
|
m_irc_connector.IsBackground = true;
|
||||||
}
|
}
|
||||||
if (!m_irc_connector.IsAlive) { m_irc_connector.Start(); }
|
if (!m_irc_connector.IsAlive) {
|
||||||
|
m_irc_connector.Start();
|
||||||
|
OpenSim.Framework.ThreadTracker.Add(m_irc_connector);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@ -260,7 +263,10 @@ namespace OpenSim.Region.Environment.Modules
|
||||||
m_irc_connector.Name = "IRCConnectorThread";
|
m_irc_connector.Name = "IRCConnectorThread";
|
||||||
m_irc_connector.IsBackground = true;
|
m_irc_connector.IsBackground = true;
|
||||||
}
|
}
|
||||||
if (!m_irc_connector.IsAlive) { m_irc_connector.Start(); }
|
if (!m_irc_connector.IsAlive) {
|
||||||
|
m_irc_connector.Start();
|
||||||
|
OpenSim.Framework.ThreadTracker.Add(m_irc_connector);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@ -421,11 +427,13 @@ namespace OpenSim.Region.Environment.Modules
|
||||||
pingSender.Name = "PingSenderThread";
|
pingSender.Name = "PingSenderThread";
|
||||||
pingSender.IsBackground = true;
|
pingSender.IsBackground = true;
|
||||||
pingSender.Start();
|
pingSender.Start();
|
||||||
|
OpenSim.Framework.ThreadTracker.Add(pingSender);
|
||||||
|
|
||||||
listener = new Thread(new ThreadStart(ListenerRun));
|
listener = new Thread(new ThreadStart(ListenerRun));
|
||||||
listener.Name = "IRCChatModuleListenerThread";
|
listener.Name = "IRCChatModuleListenerThread";
|
||||||
listener.IsBackground = true;
|
listener.IsBackground = true;
|
||||||
listener.Start();
|
listener.Start();
|
||||||
|
OpenSim.Framework.ThreadTracker.Add(listener);
|
||||||
|
|
||||||
m_writer.WriteLine(m_user);
|
m_writer.WriteLine(m_user);
|
||||||
m_writer.Flush();
|
m_writer.Flush();
|
||||||
|
|
|
@ -287,6 +287,7 @@ namespace OpenSim.Region.Environment.Modules
|
||||||
httpThread.IsBackground = true;
|
httpThread.IsBackground = true;
|
||||||
finished = false;
|
finished = false;
|
||||||
httpThread.Start();
|
httpThread.Start();
|
||||||
|
OpenSim.Framework.ThreadTracker.Add(httpThread);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -75,6 +75,7 @@ namespace OpenSim.Region.Environment.Modules
|
||||||
m_thread.Name = "ProcessTextureSenderThread";
|
m_thread.Name = "ProcessTextureSenderThread";
|
||||||
m_thread.IsBackground = true;
|
m_thread.IsBackground = true;
|
||||||
m_thread.Start();
|
m_thread.Start();
|
||||||
|
OpenSim.Framework.ThreadTracker.Add(m_thread);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_scenes.Contains(scene))
|
if (!m_scenes.Contains(scene))
|
||||||
|
|
|
@ -584,6 +584,7 @@ namespace OpenSim.Region.Environment.Modules
|
||||||
httpThread.IsBackground = true;
|
httpThread.IsBackground = true;
|
||||||
finished = false;
|
finished = false;
|
||||||
httpThread.Start();
|
httpThread.Start();
|
||||||
|
OpenSim.Framework.ThreadTracker.Add(httpThread);
|
||||||
|
|
||||||
return reqID;
|
return reqID;
|
||||||
|
|
||||||
|
|
|
@ -57,6 +57,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
|
||||||
cmdHandlerThread.Priority = ThreadPriority.BelowNormal;
|
cmdHandlerThread.Priority = ThreadPriority.BelowNormal;
|
||||||
cmdHandlerThread.IsBackground = true;
|
cmdHandlerThread.IsBackground = true;
|
||||||
cmdHandlerThread.Start();
|
cmdHandlerThread.Start();
|
||||||
|
OpenSim.Framework.ThreadTracker.Add(cmdHandlerThread);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ReadConfig()
|
public void ReadConfig()
|
||||||
|
|
|
@ -117,6 +117,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
|
||||||
EventQueueThread.Priority = MyThreadPriority;
|
EventQueueThread.Priority = MyThreadPriority;
|
||||||
EventQueueThread.Name = "EventQueueManagerThread_" + ThreadCount;
|
EventQueueThread.Name = "EventQueueManagerThread_" + ThreadCount;
|
||||||
EventQueueThread.Start();
|
EventQueueThread.Start();
|
||||||
|
OpenSim.Framework.ThreadTracker.Add(EventQueueThread);
|
||||||
|
|
||||||
// Look at this... Don't you wish everyone did that solid coding everywhere? :P
|
// Look at this... Don't you wish everyone did that solid coding everywhere? :P
|
||||||
if (ThreadCount == int.MaxValue)
|
if (ThreadCount == int.MaxValue)
|
||||||
|
|
|
@ -78,6 +78,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
|
||||||
MaintenanceThreadThread.Name = "ScriptMaintenanceThread";
|
MaintenanceThreadThread.Name = "ScriptMaintenanceThread";
|
||||||
MaintenanceThreadThread.IsBackground = true;
|
MaintenanceThreadThread.IsBackground = true;
|
||||||
MaintenanceThreadThread.Start();
|
MaintenanceThreadThread.Start();
|
||||||
|
OpenSim.Framework.ThreadTracker.Add(MaintenanceThreadThread);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -160,6 +160,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
|
||||||
t.IsBackground = true;
|
t.IsBackground = true;
|
||||||
t.Priority = ThreadPriority.Normal;
|
t.Priority = ThreadPriority.Normal;
|
||||||
t.Start();
|
t.Start();
|
||||||
|
OpenSim.Framework.ThreadTracker.Add(t);
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -118,6 +118,7 @@ namespace pCampBot
|
||||||
m_td[pos].IsBackground = true;
|
m_td[pos].IsBackground = true;
|
||||||
m_td[pos].Start();
|
m_td[pos].Start();
|
||||||
m_lBot.Add(pb);
|
m_lBot.Add(pb);
|
||||||
|
OpenSim.Framework.ThreadTracker.Add(m_td[pos]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
Loading…
Reference in New Issue