From 39e68833b23d789cbeea8e4673bc3a50b476d79c Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Thu, 7 Aug 2008 15:32:39 +0000 Subject: [PATCH] Patch #9159 Complete the support for dupe tracking. Eliminate one of the "Eternal caches". --- .../ClientStack/LindenUDP/LLPacketHandler.cs | 43 ++++++++++++------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs b/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs index 51448f2333..8c114672ae 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs @@ -144,7 +144,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP // private Dictionary m_DupeTracker = new Dictionary(); - //private uint m_DupeTrackerWindow = 30; + private uint m_DupeTrackerWindow = 30; + private int m_DupeTrackerLastCheck = System.Environment.TickCount; // Values for the SimStatsReporter // @@ -459,21 +460,29 @@ namespace OpenSim.Region.ClientStack.LindenUDP // We can't keep an unlimited record of dupes. This will prune the // dictionary by age. // -// private void PruneDupeTracker() -// { -// lock (m_DupeTracker) -// { -// Dictionary packs = -// new Dictionary(m_DupeTracker); -// -// foreach (uint pack in packs.Keys) -// { -// if (Util.UnixTimeSinceEpoch() - m_DupeTracker[pack] > -// m_DupeTrackerWindow) -// m_DupeTracker.Remove(pack); -// } -// } -// } + private void PruneDupeTracker() + { + lock (m_DupeTracker) + { + if(m_DupeTracker.Count < 1024) + return; + + if(System.Environment.TickCount - m_DupeTrackerLastCheck < 2000) + return; + + m_DupeTrackerLastCheck = System.Environment.TickCount; + + Dictionary packs = + new Dictionary(m_DupeTracker); + + foreach (uint pack in packs.Keys) + { + if (Util.UnixTimeSinceEpoch() - m_DupeTracker[pack] > + m_DupeTrackerWindow) + m_DupeTracker.Remove(pack); + } + } + } public void InPacket(Packet packet) { @@ -545,6 +554,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (packet.Type != PacketType.AgentUpdate) m_PacketsReceived++; + PruneDupeTracker(); + // Check for duplicate packets.. packets that the client is // resending because it didn't receive our ack //