From 80c1c10407a87f4154f8426b64dcf1be6c425acb Mon Sep 17 00:00:00 2001 From: MW Date: Thu, 14 May 2009 18:29:47 +0000 Subject: Added a bool variable to OGS1GridServices to be able to turn off the use of the remoteRegionInfoCache as caching region data like that stops a dynamic grid (where regions could change port or host at any time, useful for load balancing among other things) from working. The bool is currently hardcoded to be true (to use the cache). So need to hook this up to a config option later. --- .../Region/Communications/OGS1/OGS1GridServices.cs | 25 ++++++++++++++-------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs index 4ffb36f..f6da1e4 100644 --- a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs +++ b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs @@ -46,6 +46,7 @@ namespace OpenSim.Region.Communications.OGS1 { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private bool m_useRemoteRegionCache = true; /// /// Encapsulate local backend services for manipulation of local regions /// @@ -372,7 +373,7 @@ namespace OpenSim.Region.Communications.OGS1 } regionInfo = buildRegionInfo(responseData, String.Empty); - if (requestData.ContainsKey("regionHandle")) + if ((m_useRemoteRegionCache) && (requestData.ContainsKey("regionHandle"))) { m_remoteRegionInfoCache.Add(Convert.ToUInt64((string) requestData["regionHandle"]), regionInfo); } @@ -394,7 +395,7 @@ namespace OpenSim.Region.Communications.OGS1 return regionInfo; } - if (!m_remoteRegionInfoCache.TryGetValue(regionHandle, out regionInfo)) + if((!m_useRemoteRegionCache) || (!m_remoteRegionInfoCache.TryGetValue(regionHandle, out regionInfo))) { try { @@ -437,11 +438,14 @@ namespace OpenSim.Region.Communications.OGS1 //IPEndPoint neighbourInternalEndPoint = new IPEndPoint(IPAddress.Parse(internalIpStr), (int) port); regionInfo = RegionInfo.Create(regionID, regionName, regX, regY, externalHostName, httpPort, simPort, remotingPort, simURI ); - lock (m_remoteRegionInfoCache) + if (m_useRemoteRegionCache) { - if (!m_remoteRegionInfoCache.ContainsKey(regionHandle)) + lock (m_remoteRegionInfoCache) { - m_remoteRegionInfoCache.Add(regionHandle, regionInfo); + if (!m_remoteRegionInfoCache.ContainsKey(regionHandle)) + { + m_remoteRegionInfoCache.Add(regionHandle, regionInfo); + } } } } @@ -481,10 +485,13 @@ namespace OpenSim.Region.Communications.OGS1 public RegionInfo RequestClosestRegion(string regionName) { - foreach (RegionInfo ri in m_remoteRegionInfoCache.Values) + if (m_useRemoteRegionCache) { - if (ri.RegionName == regionName) - return ri; + foreach (RegionInfo ri in m_remoteRegionInfoCache.Values) + { + if (ri.RegionName == regionName) + return ri; + } } RegionInfo regionInfo = null; @@ -508,7 +515,7 @@ namespace OpenSim.Region.Communications.OGS1 regionInfo = buildRegionInfo(responseData, ""); - if (!m_remoteRegionInfoCache.ContainsKey(regionInfo.RegionHandle)) + if ((m_useRemoteRegionCache) && (!m_remoteRegionInfoCache.ContainsKey(regionInfo.RegionHandle))) m_remoteRegionInfoCache.Add(regionInfo.RegionHandle, regionInfo); } catch -- cgit v1.1