From 3a2d4c8b055d906b4a790bf1bf9fb1f09f9781ea Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Wed, 22 Jul 2015 20:13:53 +0300 Subject: Added logging in places where regions are searched for by their location This commit also fixes the log message "Region already exists in coordinates <{0},{1}>": it was actually showing the *requested* coordinates, instead of the coordinates of the previously-existing link. --- .../Grid/LocalGridServiceConnector.cs | 27 ++++++++++++++-------- .../Grid/RemoteGridServiceConnector.cs | 21 ++++++++++++++++- 2 files changed, 38 insertions(+), 10 deletions(-) (limited to 'OpenSim/Region/CoreModules/ServiceConnectorsOut') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs index 4661c21..664aba9 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs @@ -198,8 +198,15 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid public GridRegion GetRegionByPosition(UUID scopeID, int x, int y) { GridRegion region = null; -// uint regionX = Util.WorldToRegionLoc((uint)x); -// uint regionY = Util.WorldToRegionLoc((uint)y); + uint regionX = Util.WorldToRegionLoc((uint)x); + uint regionY = Util.WorldToRegionLoc((uint)y); + + // Sanity check + if ((Util.RegionToWorldLoc(regionX) != (uint)x) || (Util.RegionToWorldLoc(regionY) != (uint)y)) + { + m_log.WarnFormat("{0} GetRegionByPosition. Bad position requested: not the base of the region. Requested Pos=<{1},{2}>, Should Be=<{3},{4}>", + LogHeader, x, y, Util.RegionToWorldLoc(regionX), Util.RegionToWorldLoc(regionY)); + } // First see if it's a neighbour, even if it isn't on this sim. // Neighbour data is cached in memory, so this is fast @@ -211,8 +218,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid region = rcache.GetRegionByPosition(x, y); if (region != null) { - // m_log.DebugFormat("{0} GetRegionByPosition. Found region {1} in cache. Pos=<{2},{3}>", - // LogHeader, region.RegionName, x, y); + m_log.DebugFormat("{0} GetRegionByPosition. Found region {1} in cache (of region {2}). Pos=<{3},{4}>", + LogHeader, region.RegionName, + Util.WorldToRegionLoc((uint)region.RegionLocX), Util.WorldToRegionLoc((uint)region.RegionLocY)); break; } } @@ -222,19 +230,20 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid if (region == null) { region = m_GridService.GetRegionByPosition(scopeID, x, y); - /* + if (region == null) { m_log.DebugFormat("{0} GetRegionByPosition. Region not found by grid service. Pos=<{1},{2}>", - LogHeader, regionX, regionY); + LogHeader, regionX, regionY); } else { - m_log.DebugFormat("{0} GetRegionByPosition. Requested region {1} from grid service. Pos=<{2},{3}>", - LogHeader, region.RegionName, regionX, regionY); + m_log.DebugFormat("{0} GetRegionByPosition. Got region {1} from grid service. Pos=<{2},{3}>", + LogHeader, region.RegionName, + Util.WorldToRegionLoc((uint)region.RegionLocX), Util.WorldToRegionLoc((uint)region.RegionLocY)); } - */ } + return region; } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs index f0c4926..68ae4fa 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs @@ -193,16 +193,35 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid // The coordinates are world coords (meters), NOT region units. public GridRegion GetRegionByPosition(UUID scopeID, int x, int y) { + ulong regionHandle = Util.RegionWorldLocToHandle((uint)x, (uint)y); + uint regionX = Util.WorldToRegionLoc((uint)x); + uint regionY = Util.WorldToRegionLoc((uint)y); + + // Sanity check + if ((Util.RegionToWorldLoc(regionX) != (uint)x) || (Util.RegionToWorldLoc(regionY) != (uint)y)) + { + m_log.WarnFormat("[REMOTE GRID CONNECTOR]: GetRegionByPosition. Bad position requested: not the base of the region. Requested Pos=<{0},{1}>, Should Be=<{2},{3}>", + x, y, Util.RegionToWorldLoc(regionX), Util.RegionToWorldLoc(regionY)); + } + bool inCache = false; - GridRegion rinfo = m_RegionInfoCache.Get(scopeID, Util.RegionWorldLocToHandle((uint)x, (uint)y), out inCache); + GridRegion rinfo = m_RegionInfoCache.Get(scopeID, regionHandle, out inCache); if (inCache) + { + m_log.DebugFormat("[REMOTE GRID CONNECTOR]: GetRegionByPosition. Found region {0} in cache. Pos=<{1},{2}>, RegionHandle={3}", + (rinfo == null) ? "" : rinfo.RegionName, regionX, regionY, (rinfo == null) ? regionHandle : rinfo.RegionHandle); return rinfo; + } rinfo = m_LocalGridService.GetRegionByPosition(scopeID, x, y); if (rinfo == null) rinfo = m_RemoteGridService.GetRegionByPosition(scopeID, x, y); m_RegionInfoCache.Cache(rinfo); + + m_log.DebugFormat("[REMOTE GRID CONNECTOR]: GetRegionByPosition. Added region {0} to the cache. Pos=<{1},{2}>, RegionHandle={3}", + (rinfo == null) ? "" : rinfo.RegionName, regionX, regionY, (rinfo == null) ? regionHandle : rinfo.RegionHandle); + return rinfo; } -- cgit v1.1