From f16d36627f949a3568fea09dddcb76c9f8d823e6 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 27 Nov 2015 05:00:11 +0000 Subject: [PATCH] change threading on GetTexture and GetMesh NonSharable region modules --- .../ClientStack/Linden/Caps/GetMeshModule.cs | 39 ++++++++------- .../Linden/Caps/GetTextureModule.cs | 49 +++++++++---------- 2 files changed, 44 insertions(+), 44 deletions(-) diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs index b5a7004049..f5b439b450 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs @@ -57,8 +57,10 @@ namespace OpenSim.Region.ClientStack.Linden // LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private Scene m_scene; + private string m_SceneName = ""; private IAssetService m_AssetService; private bool m_Enabled = true; + private bool m_IsRunning = false; private string m_URL; private string m_URL2; @@ -87,7 +89,7 @@ namespace OpenSim.Region.ClientStack.Linden private IAssetService m_assetService = null; private Dictionary m_capsDict = new Dictionary(); - private static Thread[] m_workerThreads = null; + private Thread[] m_workerThreads = null; private static OpenMetaverse.BlockingQueue m_queue = new OpenMetaverse.BlockingQueue(); @@ -97,13 +99,6 @@ namespace OpenSim.Region.ClientStack.Linden #region Region Module interfaceBase Members - ~GetMeshModule() - { - foreach (Thread t in m_workerThreads) - Watchdog.AbortThread(t.ManagedThreadId); - - } - public Type ReplaceableInterface { get { return null; } @@ -167,6 +162,9 @@ namespace OpenSim.Region.ClientStack.Linden m_scene.EventManager.OnDeregisterCaps += DeregisterCaps; m_scene.EventManager.OnThrottleUpdate += ThrottleUpdate; + m_IsRunning = true; + m_SceneName = m_scene.Name; + if (m_workerThreads == null) { m_workerThreads = new Thread[2]; @@ -174,7 +172,7 @@ namespace OpenSim.Region.ClientStack.Linden for (uint i = 0; i < 2; i++) { m_workerThreads[i] = WorkManager.StartThread(DoMeshRequests, - String.Format("MeshWorkerThread{0}", i), + String.Format("GetMeshWorker[{0}]{1}",m_SceneName, i), ThreadPriority.Normal, false, false, @@ -182,11 +180,19 @@ namespace OpenSim.Region.ClientStack.Linden int.MaxValue); } } - } - - public void Close() { } + public void Close() + { + if(m_IsRunning && m_workerThreads != null) + { + m_log.DebugFormat("[GetMeshModule] Closing{0}", m_SceneName); + m_IsRunning = false; + foreach (Thread t in m_workerThreads) + Watchdog.AbortThread(t.ManagedThreadId); + } + m_queue.Clear(); + } public string Name { get { return "GetMeshModule"; } } @@ -194,10 +200,10 @@ namespace OpenSim.Region.ClientStack.Linden private void DoMeshRequests() { - while (true) + while (m_IsRunning) { aPollRequest poolreq = m_queue.Dequeue(); - + Watchdog.UpdateThread(); poolreq.thepoll.Process(poolreq); } } @@ -386,7 +392,7 @@ namespace OpenSim.Region.ClientStack.Linden private volatile int BytesSent = 0; private int Lod3 = 0; private int Lod2 = 0; - private int Lod1 = 0; +// private int Lod1 = 0; private int UserSetThrottle = 0; private int UDPSetThrottle = 0; private int CapSetThrottle = 0; @@ -501,7 +507,7 @@ namespace OpenSim.Region.ClientStack.Linden { Lod3 = 0; Lod2 = 0; - Lod1 = 0; +// Lod1 = 0; } } } @@ -534,6 +540,5 @@ namespace OpenSim.Region.ClientStack.Linden } } - } } diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs index aa51a0073f..81170b89b6 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs @@ -75,7 +75,7 @@ namespace OpenSim.Region.ClientStack.Linden private IAssetService m_assetService = null; private Dictionary m_capsDict = new Dictionary(); - private static Thread[] m_workerThreads = null; + private Thread[] m_workerThreads = null; private string m_Url = "localhost"; @@ -84,7 +84,8 @@ namespace OpenSim.Region.ClientStack.Linden private Dictionary m_pollservices = new Dictionary(); - + private bool m_IsRunning = false; + private string m_SceneName = ""; #region ISharedRegionModule Members public void Initialise(IConfigSource source) @@ -128,6 +129,9 @@ namespace OpenSim.Region.ClientStack.Linden m_scene.EventManager.OnDeregisterCaps += DeregisterCaps; m_scene.EventManager.OnThrottleUpdate += ThrottleUpdate; + m_SceneName = m_scene.Name; + m_IsRunning = true; + if (m_workerThreads == null) { m_workerThreads = new Thread[2]; @@ -135,7 +139,7 @@ namespace OpenSim.Region.ClientStack.Linden for (uint i = 0; i < 2; i++) { m_workerThreads[i] = WorkManager.StartThread(DoTextureRequests, - String.Format("TextureWorkerThread{0}", i), + String.Format("GetTextureWorker[{0}]{1}",m_SceneName, i), ThreadPriority.Normal, false, false, @@ -165,17 +169,6 @@ namespace OpenSim.Region.ClientStack.Linden adjData = pthrottles; } - // 0.125f converts from bits to bytes - //int resend = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); - //pos += 4; - // int land = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); - //pos += 4; - // int wind = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); - // pos += 4; - // int cloud = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); - // pos += 4; - // int task = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); - // pos += 4; pos = pos + 20; int texture = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); //pos += 4; //int asset = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); @@ -199,7 +192,17 @@ namespace OpenSim.Region.ClientStack.Linden { } - public void Close() { } + public void Close() + { + if(m_IsRunning && m_workerThreads != null) + { + m_log.DebugFormat("[GetTextureModule] Closing {0}", m_SceneName); + m_IsRunning = false; + foreach (Thread t in m_workerThreads) + Watchdog.AbortThread(t.ManagedThreadId); + } + m_queue.Clear(); + } public string Name { get { return "GetTextureModule"; } } @@ -210,13 +213,6 @@ namespace OpenSim.Region.ClientStack.Linden #endregion - ~GetTextureModule() - { - foreach (Thread t in m_workerThreads) - Watchdog.AbortThread(t.ManagedThreadId); - - } - private class PollServiceTextureEventArgs : PollServiceEventArgs { private List requests = @@ -414,13 +410,14 @@ namespace OpenSim.Region.ClientStack.Linden private void DoTextureRequests() { - while (true) + while (m_IsRunning) { aPollRequest poolreq = m_queue.Dequeue(); - + Watchdog.UpdateThread(); poolreq.thepoll.Process(poolreq); } } + internal sealed class CapsDataThrottler { @@ -498,7 +495,5 @@ namespace OpenSim.Region.ClientStack.Linden } public int ThrottleBytes; } - } - - + } }