From c044e4d45882d9a033a89696b42822b218e6b469 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 16 Mar 2022 10:33:23 +0000 Subject: [PATCH] change entity transfer BannedRegionCache --- .../EntityTransfer/EntityTransferModule.cs | 33 +++++++++---------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index a32f3c54e6..591be543a1 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -142,8 +142,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer // to the grid service. private class BannedRegionCache { - private ExpiringCacheOS> m_bannedRegions = - new ExpiringCacheOS>(15000); + private ExpiringCacheOS> m_bannedRegions = + new ExpiringCacheOS>(15000); public BannedRegionCache() { @@ -172,16 +172,16 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer // Return 'true' if there is a valid ban entry for this agent in this region public bool IfBanned(ulong pRegionHandle, UUID pAgentID) { - if (m_bannedRegions.TryGetValue(pAgentID, out Dictionary idCache)) + if (m_bannedRegions.TryGetValue(pRegionHandle, out Dictionary idCache)) { lock(idCache) { - if (idCache.TryGetValue(pRegionHandle, out double exp)) + if (idCache.TryGetValue(pAgentID, out double exp)) { if(exp < Util.GetTimeStamp()) return true; else - idCache.Remove(pRegionHandle); + idCache.Remove(pAgentID); } } } @@ -190,30 +190,29 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer public void Add(ulong pRegionHandle, UUID pAgentID, double newTime) { - Dictionary idCache; - if (!m_bannedRegions.TryGetValue(pAgentID, out idCache)) + if (m_bannedRegions.TryGetValue(pRegionHandle, out Dictionary idCache)) { - idCache = new Dictionary(); - idCache[pRegionHandle] = Util.GetTimeStamp() + newTime; - m_bannedRegions.AddOrUpdate(pAgentID, idCache, newTime); + lock (idCache) + { + idCache[pAgentID] = Util.GetTimeStamp() + newTime; + m_bannedRegions.AddOrUpdate(pRegionHandle, idCache, newTime); + } } else { - lock(idCache) - { - idCache[pRegionHandle] = Util.GetTimeStamp() + newTime; - m_bannedRegions.AddOrUpdate(pAgentID, idCache, newTime); - } + idCache = new Dictionary(); + idCache[pAgentID] = Util.GetTimeStamp() + newTime; + m_bannedRegions.AddOrUpdate(pRegionHandle, idCache, newTime); } } // Remove the agent from the region's banned list public void Remove(ulong pRegionHandle, UUID pAgentID) { - if (m_bannedRegions.TryGetValue(pAgentID, out Dictionary idCache)) + if (m_bannedRegions.TryGetValue(pRegionHandle, out Dictionary idCache)) { lock (idCache) - idCache.Remove(pRegionHandle); + idCache.Remove(pAgentID); } } }