From 6bc76860d185ba6296f268373ccfea6375fff611 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 5 Nov 2016 23:56:55 +0000 Subject: avoid a null ref, few changes to udp updates send --- .../Region/ClientStack/Linden/UDP/LLClientView.cs | 32 ++++------------------ .../Region/ClientStack/Linden/UDP/LLUDPClient.cs | 30 +++++++------------- 2 files changed, 15 insertions(+), 47 deletions(-) (limited to 'OpenSim/Region/ClientStack') diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 17e4400..276b367 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -4632,28 +4632,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP void HandleQueueEmpty(ThrottleOutPacketTypeFlags categories) { -// if (!m_udpServer.IsRunningOutbound) -// return; - if ((categories & ThrottleOutPacketTypeFlags.Task) != 0) { -// if (!m_udpServer.IsRunningOutbound) -// return; -/* - if (m_maxUpdates == 0 || m_LastQueueFill == 0) - { - m_maxUpdates = m_udpServer.PrimUpdatesPerCallback; - } - else - { - if (Util.EnvironmentTickCountSubtract(m_LastQueueFill) < 200) - m_maxUpdates += 5; - else - m_maxUpdates = m_maxUpdates >> 1; - } - m_maxUpdates = Util.Clamp(m_maxUpdates,10,500); - m_LastQueueFill = Util.EnvironmentTickCount(); -*/ int maxUpdateBytes = m_udpClient.GetCatBytesCanSend(ThrottleOutPacketType.Task, 30); if (m_entityUpdates.Count > 0) @@ -4669,23 +4649,21 @@ namespace OpenSim.Region.ClientStack.LindenUDP internal bool HandleHasUpdates(ThrottleOutPacketTypeFlags categories) { - bool hasUpdates = false; - if ((categories & ThrottleOutPacketTypeFlags.Task) != 0) { if (m_entityUpdates.Count > 0) - hasUpdates = true; - else if (m_entityProps.Count > 0) - hasUpdates = true; + return true; + if (m_entityProps.Count > 0) + return true; } if ((categories & ThrottleOutPacketTypeFlags.Texture) != 0) { if (ImageManager.HasUpdates()) - hasUpdates = true; + return true; } - return hasUpdates; + return false; } public void SendAssetUploadCompleteMessage(sbyte AssetType, bool Success, UUID AssetFullID) diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs index 4e68a9b..246f003 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs @@ -166,7 +166,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// Total number of sent packets that we have reported to the OnPacketStats event(s) private int m_packetsSentReported; /// Holds the Environment.TickCount value of when the next OnQueueEmpty can be fired - private int m_nextOnQueueEmpty = 1; + private double m_nextOnQueueEmpty = 0; /// Throttle bucket for this agent's connection private readonly AdaptiveTokenBucket m_throttleClient; @@ -771,7 +771,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP RTO = Math.Min(RTO * 2, m_maxRTO); } - const int MIN_CALLBACK_MS = 20; + const double MIN_CALLBACK_MS = 20.0; + private bool m_isQueueEmptyRunning; /// /// Does an early check to see if this queue empty callback is already @@ -782,35 +783,24 @@ namespace OpenSim.Region.ClientStack.LindenUDP { if (!m_isQueueEmptyRunning) { - int start = Environment.TickCount & Int32.MaxValue; + if (!HasUpdates(categories)) + return; + double start = Util.GetTimeStampMS(); if (start < m_nextOnQueueEmpty) return; m_isQueueEmptyRunning = true; - m_nextOnQueueEmpty = start + MIN_CALLBACK_MS; - if (m_nextOnQueueEmpty == 0) - m_nextOnQueueEmpty = 1; - if (HasUpdates(categories)) - { - if (!m_udpServer.OqrEngine.IsRunning) - { - // Asynchronously run the callback - Util.FireAndForget(FireQueueEmpty, categories, "LLUDPClient.BeginFireQueueEmpty"); - } - else - { - m_udpServer.OqrEngine.QueueJob(AgentID.ToString(), () => FireQueueEmpty(categories)); - } - } + // Asynchronously run the callback + if (m_udpServer.OqrEngine.IsRunning) + m_udpServer.OqrEngine.QueueJob(AgentID.ToString(), () => FireQueueEmpty(categories)); else - m_isQueueEmptyRunning = false; + Util.FireAndForget(FireQueueEmpty, categories, "LLUDPClient.BeginFireQueueEmpty"); } } - private bool m_isQueueEmptyRunning; /// -- cgit v1.1