From 96a24491222e29ba8d615d9ffaf63e72742a9cc7 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Wed, 17 Sep 2014 20:03:54 -0400 Subject: [PATCH] Undo "Revert "Small changes to threading to send thread names to unmanaged threads. Needs Mono 3.6+ to see thread names in utilities like top -H . Some formatting of the thread name to fin in the 16 byte limit on Linux. Please test on Windows to see if the work has any adverse effects."" Fix for break in next commit This reverts commit 376fab140227e92dbd841436509a97b87c9e7792. --- OpenSim/Framework/Monitoring/Watchdog.cs | 13 +++++++------ .../Servers/HttpServer/OSHttpRequestPump.cs | 4 ++-- .../Framework/Servers/HttpServer/OSHttpServer.cs | 2 +- OpenSim/Region/Framework/Scenes/Scene.cs | 4 +++- ThirdParty/SmartThreadPool/SmartThreadPool.cs | 2 +- 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/OpenSim/Framework/Monitoring/Watchdog.cs b/OpenSim/Framework/Monitoring/Watchdog.cs index e9e7bd21c0..e9f22f1b07 100644 --- a/OpenSim/Framework/Monitoring/Watchdog.cs +++ b/OpenSim/Framework/Monitoring/Watchdog.cs @@ -87,7 +87,7 @@ namespace OpenSim.Framework.Monitoring /// public Stat Stat { get; set; } - public ThreadWatchdogInfo(Thread thread, int timeout) + public ThreadWatchdogInfo(Thread thread, int timeout, string name) { Thread = thread; Timeout = timeout; @@ -96,8 +96,8 @@ namespace OpenSim.Framework.Monitoring Stat = new Stat( - thread.Name, - string.Format("Last update of thread {0}", thread.Name), + name, + string.Format("Last update of thread {0}", name), "", "ms", "server", @@ -216,12 +216,11 @@ namespace OpenSim.Framework.Monitoring bool alarmIfTimeout, Func alarmMethod, int timeout, bool log = true) { Thread thread = new Thread(start); - thread.Name = name; thread.Priority = priority; thread.IsBackground = isBackground; ThreadWatchdogInfo twi - = new ThreadWatchdogInfo(thread, timeout) + = new ThreadWatchdogInfo(thread, timeout, name) { AlarmIfTimeout = alarmIfTimeout, AlarmMethod = alarmMethod }; if (log) @@ -230,8 +229,10 @@ namespace OpenSim.Framework.Monitoring lock (m_threads) m_threads.Add(twi.Thread.ManagedThreadId, twi); - + thread.Start(); + thread.Name = name; + return thread; } diff --git a/OpenSim/Framework/Servers/HttpServer/OSHttpRequestPump.cs b/OpenSim/Framework/Servers/HttpServer/OSHttpRequestPump.cs index 77cfb7e472..bdea278810 100644 --- a/OpenSim/Framework/Servers/HttpServer/OSHttpRequestPump.cs +++ b/OpenSim/Framework/Servers/HttpServer/OSHttpRequestPump.cs @@ -70,9 +70,9 @@ namespace OpenSim.Framework.Servers.HttpServer _id = id; _engine = new Thread(new ThreadStart(Engine)); - _engine.Name = EngineID; _engine.IsBackground = true; _engine.Start(); + _engine.Name = string.Format ("Engine:{0}",EngineID); ThreadTracker.Add(_engine); } @@ -91,9 +91,9 @@ namespace OpenSim.Framework.Servers.HttpServer public void Start() { _engine = new Thread(new ThreadStart(Engine)); - _engine.Name = EngineID; _engine.IsBackground = true; _engine.Start(); + _engine.Name = string.Format ("Engine:{0}",EngineID); ThreadTracker.Add(_engine); } diff --git a/OpenSim/Framework/Servers/HttpServer/OSHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/OSHttpServer.cs index 84aa31b824..cd6284259a 100644 --- a/OpenSim/Framework/Servers/HttpServer/OSHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/OSHttpServer.cs @@ -150,9 +150,9 @@ namespace OpenSim.Framework.Servers.HttpServer public void Start() { _engine = new Thread(new ThreadStart(Engine)); - _engine.Name = _engineId; _engine.IsBackground = true; _engine.Start(); + _engine.Name = string.Format ("Engine:{0}",_engineId); ThreadTracker.Add(_engine); diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 28dbccb95f..7e4d9ed3b0 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1079,6 +1079,8 @@ namespace OpenSim.Region.Framework.Scenes StatsReporter = new SimStatsReporter(this); StatsReporter.OnSendStatsResult += SendSimStatsPackets; StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats; + + Thread.CurrentThread.Name = string.Format ("Scene:{0}", regInfo.RegionName.Replace(" ", "_")); } public Scene(RegionInfo regInfo, PhysicsScene physicsScene) : base(regInfo) @@ -1396,7 +1398,7 @@ namespace OpenSim.Region.Framework.Scenes m_heartbeatThread = Watchdog.StartThread( - Heartbeat, string.Format("Heartbeat ({0})", RegionInfo.RegionName), ThreadPriority.Normal, false, false); + Heartbeat, string.Format("Heartbeat-({0})", RegionInfo.RegionName.Replace(" ", "_")), ThreadPriority.Normal, false, false); StartScripts(); } diff --git a/ThirdParty/SmartThreadPool/SmartThreadPool.cs b/ThirdParty/SmartThreadPool/SmartThreadPool.cs index a4f4ce5695..615518ecf1 100644 --- a/ThirdParty/SmartThreadPool/SmartThreadPool.cs +++ b/ThirdParty/SmartThreadPool/SmartThreadPool.cs @@ -677,7 +677,6 @@ namespace Amib.Threading : new Thread(ProcessQueuedItems); #endif // Configure the new thread and start it - workerThread.Name = "STP " + Name + " Thread #" + _threadCounter; workerThread.IsBackground = _stpStartInfo.AreThreadsBackground; #if !(_SILVERLIGHT) && !(_WINDOWS_CE) && !(WINDOWS_PHONE) @@ -691,6 +690,7 @@ namespace Amib.Threading workerThread.Priority = _stpStartInfo.ThreadPriority; #endif workerThread.Start(); + workerThread.Name = string.Format("STP:{0}:{1}", Name, _threadCounter); ++_threadCounter; // Add it to the dictionary and update its creation time.