From ad43cc6784b5422c5b7125a4f9356a3fa7fe2aee Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 13 Jun 2017 19:04:18 +0100 Subject: change llclient async udp packets processing. Removed the shared Jobengine that made only one thread do some packets for all users, and removed the FireAndForget, so each user could issue a unlimited number of threads. Added a new JobEngine per client, so each gets at most one thread,and that thread can be released if iddle (for 5 seconds ) --- OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | 12 ++++++++---- OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs | 14 +++++++------- 2 files changed, 15 insertions(+), 11 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index d22f75e..54359eb 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -325,6 +325,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// public LLImageManager ImageManager { get; private set; } + public JobEngine m_asyncPacketProcess; private readonly LLUDPServer m_udpServer; private readonly LLUDPClient m_udpClient; private readonly UUID m_sessionId; @@ -378,7 +379,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP protected Scene m_scene; protected string m_firstName; protected string m_lastName; - protected Thread m_clientThread; protected Vector3 m_startpos; protected UUID m_activeGroupID; protected string m_activeGroupName = String.Empty; @@ -529,7 +529,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP m_prioritizer = new Prioritizer(m_scene); RegisterLocalPacketHandlers(); - + string name = string.Format("AsyncInUDP-{0}",m_agentId.ToString()); + m_asyncPacketProcess = new JobEngine(name, name, 10000); IsActive = true; } @@ -592,6 +593,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (OnConnectionClosed != null) OnConnectionClosed(this); + m_asyncPacketProcess.Stop(); // Flush all of the packets out of the UDP server for this client if (m_udpServer != null) @@ -778,12 +780,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP cinfo.AsyncRequests[packet.Type.ToString()]++; object obj = new AsyncPacketProcess(this, pprocessor.method, packet); - +/* if (pprocessor.InEngine) m_udpServer.IpahEngine.QueueJob(packet.Type.ToString(), () => ProcessSpecificPacketAsync(obj)); else Util.FireAndForget(ProcessSpecificPacketAsync, obj, packet.Type.ToString()); - +*/ + m_asyncPacketProcess.QueueJob(packet.Type.ToString(), () => ProcessSpecificPacketAsync(obj)); result = true; } else @@ -841,6 +844,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP public virtual void Start() { + m_asyncPacketProcess.Start(); m_scene.AddNewAgent(this, PresenceType.User); // RefreshGroupMembership(); diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs index 171e1cf..b575ed9 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs @@ -414,7 +414,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// Queue some low priority but potentially high volume async requests so that they don't overwhelm available /// threadpool threads. /// - public JobEngine IpahEngine { get; protected set; } +// public JobEngine IpahEngine { get; protected set; } /// /// Run queue empty processing within a single persistent thread. @@ -527,7 +527,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP { StartInbound(); StartOutbound(); - IpahEngine.Start(); +// IpahEngine.Start(); OqrEngine.Start(); m_elapsedMSSinceLastStatReport = Environment.TickCount; @@ -572,7 +572,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP m_log.Info("[LLUDPSERVER]: Shutting down the LLUDP server for " + Scene.Name); base.StopOutbound(); base.StopInbound(); - IpahEngine.Stop(); +// IpahEngine.Stop(); OqrEngine.Stop(); } @@ -691,12 +691,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP Scene = (Scene)scene; m_location = new Location(Scene.RegionInfo.RegionHandle); - +/* IpahEngine = new JobEngine( string.Format("Incoming Packet Async Handling Engine ({0})", Scene.Name), "INCOMING PACKET ASYNC HANDLING ENGINE"); - +*/ OqrEngine = new JobEngine( string.Format("Outgoing Queue Refill Engine ({0})", Scene.Name), @@ -781,7 +781,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP MeasuresOfInterest.AverageChangeOverTime, stat => stat.Value = GetTotalQueuedOutgoingPackets(), StatVerbosity.Info)); - +/* StatsManager.RegisterStat( new Stat( "IncomingPacketAsyncRequestsWaiting", @@ -794,7 +794,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP MeasuresOfInterest.None, stat => stat.Value = IpahEngine.JobsWaiting, StatVerbosity.Debug)); - +*/ StatsManager.RegisterStat( new Stat( "OQRERequestsWaiting", -- cgit v1.1