diff options
author | UbitUmarov | 2016-07-31 22:39:01 +0100 |
---|---|---|
committer | UbitUmarov | 2016-07-31 22:39:01 +0100 |
commit | c0eae1f8f99c1919338813c150e22a1d91d874ad (patch) | |
tree | e5da57efe3011504f4df717cbdf515463d0a853a /OpenSim/Region/CoreModules/Framework/EntityTransfer | |
parent | bug fix (diff) | |
download | opensim-SC_OLD-c0eae1f8f99c1919338813c150e22a1d91d874ad.zip opensim-SC_OLD-c0eae1f8f99c1919338813c150e22a1d91d874ad.tar.gz opensim-SC_OLD-c0eae1f8f99c1919338813c150e22a1d91d874ad.tar.bz2 opensim-SC_OLD-c0eae1f8f99c1919338813c150e22a1d91d874ad.tar.xz |
simply NotFoundLocationCache, comment out some debug messages
Diffstat (limited to 'OpenSim/Region/CoreModules/Framework/EntityTransfer')
-rw-r--r-- | OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs | 101 | ||||
-rw-r--r-- | OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferStateMachine.cs | 28 |
2 files changed, 55 insertions, 74 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 9ee23d6..c6cabf1 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs | |||
@@ -1537,8 +1537,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1537 | 1537 | ||
1538 | public ScenePresence CrossAsync(ScenePresence agent, bool isFlying) | 1538 | public ScenePresence CrossAsync(ScenePresence agent, bool isFlying) |
1539 | { | 1539 | { |
1540 | uint x; | ||
1541 | uint y; | ||
1542 | Vector3 newpos; | 1540 | Vector3 newpos; |
1543 | EntityTransferContext ctx = new EntityTransferContext(); | 1541 | EntityTransferContext ctx = new EntityTransferContext(); |
1544 | string failureReason; | 1542 | string failureReason; |
@@ -1814,7 +1812,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1814 | // In any case | 1812 | // In any case |
1815 | agent.IsInTransit = false; | 1813 | agent.IsInTransit = false; |
1816 | 1814 | ||
1817 | m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Crossing agent {0} {1} completed.", agent.Firstname, agent.Lastname); | 1815 | // m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Crossing agent {0} {1} completed.", agent.Firstname, agent.Lastname); |
1818 | } | 1816 | } |
1819 | 1817 | ||
1820 | #endregion | 1818 | #endregion |
@@ -2115,79 +2113,62 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
2115 | // contains that point. A conservitive estimate. | 2113 | // contains that point. A conservitive estimate. |
2116 | private class NotFoundLocationCache | 2114 | private class NotFoundLocationCache |
2117 | { | 2115 | { |
2118 | private struct NotFoundLocation | 2116 | private Dictionary<ulong, DateTime> m_notFoundLocations = new Dictionary<ulong, DateTime>(); |
2119 | { | ||
2120 | public double minX, maxX, minY, maxY; | ||
2121 | public DateTime expireTime; | ||
2122 | } | ||
2123 | private List<NotFoundLocation> m_notFoundLocations = new List<NotFoundLocation>(); | ||
2124 | public NotFoundLocationCache() | 2117 | public NotFoundLocationCache() |
2125 | { | 2118 | { |
2126 | } | 2119 | } |
2127 | // Add an area to the list of 'not found' places. The area is the snapped region | 2120 | // just use normal regions handlers and sizes |
2128 | // area around the added point. | ||
2129 | public void Add(double pX, double pY) | 2121 | public void Add(double pX, double pY) |
2130 | { | 2122 | { |
2123 | ulong psh = (ulong)pX & 0xffffff00ul; | ||
2124 | psh <<= 32; | ||
2125 | psh |= (ulong)pY & 0xffffff00ul; | ||
2126 | |||
2131 | lock (m_notFoundLocations) | 2127 | lock (m_notFoundLocations) |
2132 | { | 2128 | m_notFoundLocations[psh] = DateTime.Now + TimeSpan.FromSeconds(30);; |
2133 | if (!LockedContains(pX, pY)) | ||
2134 | { | ||
2135 | NotFoundLocation nfl = new NotFoundLocation(); | ||
2136 | // A not found location is not found for at least a whole region sized area | ||
2137 | nfl.minX = pX - (pX % (double)Constants.RegionSize); | ||
2138 | nfl.minY = pY - (pY % (double)Constants.RegionSize); | ||
2139 | nfl.maxX = nfl.minX + (double)Constants.RegionSize; | ||
2140 | nfl.maxY = nfl.minY + (double)Constants.RegionSize; | ||
2141 | nfl.expireTime = DateTime.Now + TimeSpan.FromSeconds(30); | ||
2142 | m_notFoundLocations.Add(nfl); | ||
2143 | } | ||
2144 | } | ||
2145 | |||
2146 | } | 2129 | } |
2147 | // Test to see of this point is in any of the 'not found' areas. | 2130 | // Test to see of this point is in any of the 'not found' areas. |
2148 | // Return 'true' if the point is found inside the 'not found' areas. | 2131 | // Return 'true' if the point is found inside the 'not found' areas. |
2149 | public bool Contains(double pX, double pY) | 2132 | public bool Contains(double pX, double pY) |
2150 | { | 2133 | { |
2151 | bool ret = false; | 2134 | ulong psh = (ulong)pX & 0xffffff00ul; |
2135 | psh <<= 32; | ||
2136 | psh |= (ulong)pY & 0xffffff00ul; | ||
2137 | |||
2152 | lock (m_notFoundLocations) | 2138 | lock (m_notFoundLocations) |
2153 | ret = LockedContains(pX, pY); | ||
2154 | return ret; | ||
2155 | } | ||
2156 | private bool LockedContains(double pX, double pY) | ||
2157 | { | ||
2158 | bool ret = false; | ||
2159 | this.DoExpiration(); | ||
2160 | foreach (NotFoundLocation nfl in m_notFoundLocations) | ||
2161 | { | 2139 | { |
2162 | if (pX >= nfl.minX && pX < nfl.maxX && pY >= nfl.minY && pY < nfl.maxY) | 2140 | if(m_notFoundLocations.ContainsKey(psh)) |
2163 | { | 2141 | { |
2164 | ret = true; | 2142 | if(m_notFoundLocations[psh] > DateTime.UtcNow) |
2165 | break; | 2143 | return true; |
2144 | m_notFoundLocations.Remove(psh); | ||
2166 | } | 2145 | } |
2146 | return false; | ||
2167 | } | 2147 | } |
2168 | return ret; | ||
2169 | } | 2148 | } |
2149 | |||
2170 | private void DoExpiration() | 2150 | private void DoExpiration() |
2171 | { | 2151 | { |
2172 | List<NotFoundLocation> m_toRemove = null; | 2152 | List<ulong> m_toRemove = new List<ulong>();; |
2173 | DateTime now = DateTime.Now; | 2153 | DateTime now = DateTime.UtcNow; |
2174 | foreach (NotFoundLocation nfl in m_notFoundLocations) | 2154 | lock (m_notFoundLocations) |
2175 | { | 2155 | { |
2176 | if (nfl.expireTime < now) | 2156 | foreach (KeyValuePair<ulong, DateTime> kvp in m_notFoundLocations) |
2177 | { | 2157 | { |
2178 | if (m_toRemove == null) | 2158 | if (kvp.Value < now) |
2179 | m_toRemove = new List<NotFoundLocation>(); | 2159 | m_toRemove.Add(kvp.Key); |
2180 | m_toRemove.Add(nfl); | 2160 | } |
2161 | |||
2162 | if (m_toRemove.Count > 0) | ||
2163 | { | ||
2164 | foreach (ulong u in m_toRemove) | ||
2165 | m_notFoundLocations.Remove(u); | ||
2166 | m_toRemove.Clear(); | ||
2181 | } | 2167 | } |
2182 | } | ||
2183 | if (m_toRemove != null) | ||
2184 | { | ||
2185 | foreach (NotFoundLocation nfl in m_toRemove) | ||
2186 | m_notFoundLocations.Remove(nfl); | ||
2187 | m_toRemove.Clear(); | ||
2188 | } | 2168 | } |
2189 | } | 2169 | } |
2190 | } | 2170 | } |
2171 | |||
2191 | #endregion // NotFoundLocationCache class | 2172 | #endregion // NotFoundLocationCache class |
2192 | private NotFoundLocationCache m_notFoundLocationCache = new NotFoundLocationCache(); | 2173 | private NotFoundLocationCache m_notFoundLocationCache = new NotFoundLocationCache(); |
2193 | 2174 | ||
@@ -2202,7 +2183,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
2202 | 2183 | ||
2203 | // Given a world position, get the GridRegion info for | 2184 | // Given a world position, get the GridRegion info for |
2204 | // the region containing that point. | 2185 | // the region containing that point. |
2205 | // Someday this should be a method on GridService. | 2186 | // Not needed on 0.9 grids |
2206 | // 'pSizeHint' is the size of the source region but since the destination point can be anywhere | 2187 | // 'pSizeHint' is the size of the source region but since the destination point can be anywhere |
2207 | // the size of the target region is unknown thus the search area might have to be very large. | 2188 | // the size of the target region is unknown thus the search area might have to be very large. |
2208 | // Return 'null' if no such region exists. | 2189 | // Return 'null' if no such region exists. |
@@ -2233,8 +2214,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
2233 | ret = pGridService.GetRegionByPosition(pScopeID, (int)possibleX, (int)possibleY); | 2214 | ret = pGridService.GetRegionByPosition(pScopeID, (int)possibleX, (int)possibleY); |
2234 | if (ret != null) | 2215 | if (ret != null) |
2235 | { | 2216 | { |
2236 | m_log.DebugFormat("{0} GetRegionContainingWorldLocation: Found region using legacy size. rloc=<{1},{2}>. Rname={3}", | 2217 | // m_log.DebugFormat("{0} GetRegionContainingWorldLocation: Found region using legacy size. rloc=<{1},{2}>. Rname={3}", |
2237 | LogHeader, possibleX, possibleY, ret.RegionName); | 2218 | // LogHeader, possibleX, possibleY, ret.RegionName); |
2238 | } | 2219 | } |
2239 | 2220 | ||
2240 | if (ret == null) | 2221 | if (ret == null) |
@@ -2248,21 +2229,21 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
2248 | List<GridRegion> possibleRegions = pGridService.GetRegionRange(pScopeID, | 2229 | List<GridRegion> possibleRegions = pGridService.GetRegionRange(pScopeID, |
2249 | (int)(px - range), (int)(px), | 2230 | (int)(px - range), (int)(px), |
2250 | (int)(py - range), (int)(py)); | 2231 | (int)(py - range), (int)(py)); |
2251 | m_log.DebugFormat("{0} GetRegionContainingWorldLocation: possibleRegions cnt={1}, range={2}", | 2232 | // m_log.DebugFormat("{0} GetRegionContainingWorldLocation: possibleRegions cnt={1}, range={2}", |
2252 | LogHeader, possibleRegions.Count, range); | 2233 | // LogHeader, possibleRegions.Count, range); |
2253 | if (possibleRegions != null && possibleRegions.Count > 0) | 2234 | if (possibleRegions != null && possibleRegions.Count > 0) |
2254 | { | 2235 | { |
2255 | // If we found some regions, check to see if the point is within | 2236 | // If we found some regions, check to see if the point is within |
2256 | foreach (GridRegion gr in possibleRegions) | 2237 | foreach (GridRegion gr in possibleRegions) |
2257 | { | 2238 | { |
2258 | m_log.DebugFormat("{0} GetRegionContainingWorldLocation: possibleRegion nm={1}, regionLoc=<{2},{3}>, regionSize=<{4},{5}>", | 2239 | // m_log.DebugFormat("{0} GetRegionContainingWorldLocation: possibleRegion nm={1}, regionLoc=<{2},{3}>, regionSize=<{4},{5}>", |
2259 | LogHeader, gr.RegionName, gr.RegionLocX, gr.RegionLocY, gr.RegionSizeX, gr.RegionSizeY); | 2240 | // LogHeader, gr.RegionName, gr.RegionLocX, gr.RegionLocY, gr.RegionSizeX, gr.RegionSizeY); |
2260 | if (px >= (double)gr.RegionLocX && px < (double)(gr.RegionLocX + gr.RegionSizeX) | 2241 | if (px >= (double)gr.RegionLocX && px < (double)(gr.RegionLocX + gr.RegionSizeX) |
2261 | && py >= (double)gr.RegionLocY && py < (double)(gr.RegionLocY + gr.RegionSizeY)) | 2242 | && py >= (double)gr.RegionLocY && py < (double)(gr.RegionLocY + gr.RegionSizeY)) |
2262 | { | 2243 | { |
2263 | // Found a region that contains the point | 2244 | // Found a region that contains the point |
2264 | ret = gr; | 2245 | ret = gr; |
2265 | m_log.DebugFormat("{0} GetRegionContainingWorldLocation: found. RegionName={1}", LogHeader, ret.RegionName); | 2246 | // m_log.DebugFormat("{0} GetRegionContainingWorldLocation: found. RegionName={1}", LogHeader, ret.RegionName); |
2266 | break; | 2247 | break; |
2267 | } | 2248 | } |
2268 | } | 2249 | } |
@@ -2276,7 +2257,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
2276 | { | 2257 | { |
2277 | // remember this location was not found so we can quickly not find it next time | 2258 | // remember this location was not found so we can quickly not find it next time |
2278 | m_notFoundLocationCache.Add(px, py); | 2259 | m_notFoundLocationCache.Add(px, py); |
2279 | m_log.DebugFormat("{0} GetRegionContainingWorldLocation: Not found. Remembering loc=<{1},{2}>", LogHeader, px, py); | 2260 | // m_log.DebugFormat("{0} GetRegionContainingWorldLocation: Not found. Remembering loc=<{1},{2}>", LogHeader, px, py); |
2280 | } | 2261 | } |
2281 | 2262 | ||
2282 | return ret; | 2263 | return ret; |
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferStateMachine.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferStateMachine.cs index e3c6c0d..acfdaef 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferStateMachine.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferStateMachine.cs | |||
@@ -101,7 +101,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
101 | /// <returns>true if the agent was not already in transit, false if it was</returns> | 101 | /// <returns>true if the agent was not already in transit, false if it was</returns> |
102 | internal bool SetInTransit(UUID id) | 102 | internal bool SetInTransit(UUID id) |
103 | { | 103 | { |
104 | m_log.DebugFormat("{0} SetInTransit. agent={1}, newState=Preparing", LogHeader, id); | 104 | // m_log.DebugFormat("{0} SetInTransit. agent={1}, newState=Preparing", LogHeader, id); |
105 | lock (m_agentsInTransit) | 105 | lock (m_agentsInTransit) |
106 | { | 106 | { |
107 | if (!m_agentsInTransit.ContainsKey(id)) | 107 | if (!m_agentsInTransit.ContainsKey(id)) |
@@ -123,7 +123,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
123 | /// <exception cref='Exception'>Illegal transitions will throw an Exception</exception> | 123 | /// <exception cref='Exception'>Illegal transitions will throw an Exception</exception> |
124 | internal bool UpdateInTransit(UUID id, AgentTransferState newState) | 124 | internal bool UpdateInTransit(UUID id, AgentTransferState newState) |
125 | { | 125 | { |
126 | m_log.DebugFormat("{0} UpdateInTransit. agent={1}, newState={2}", LogHeader, id, newState); | 126 | // m_log.DebugFormat("{0} UpdateInTransit. agent={1}, newState={2}", LogHeader, id, newState); |
127 | 127 | ||
128 | bool transitionOkay = false; | 128 | bool transitionOkay = false; |
129 | 129 | ||
@@ -247,32 +247,32 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
247 | { | 247 | { |
248 | AgentTransferState state = m_agentsInTransit[id]; | 248 | AgentTransferState state = m_agentsInTransit[id]; |
249 | 249 | ||
250 | if (state == AgentTransferState.Transferring || state == AgentTransferState.ReceivedAtDestination) | 250 | // if (state == AgentTransferState.Transferring || state == AgentTransferState.ReceivedAtDestination) |
251 | { | 251 | // { |
252 | // FIXME: For now, we allow exit from any state since a thrown exception in teleport is now guranteed | 252 | // FIXME: For now, we allow exit from any state since a thrown exception in teleport is now guranteed |
253 | // to be handled properly - ResetFromTransit() could be invoked at any step along the process | 253 | // to be handled properly - ResetFromTransit() could be invoked at any step along the process |
254 | m_log.WarnFormat( | 254 | // m_log.WarnFormat( |
255 | "[ENTITY TRANSFER STATE MACHINE]: Agent with ID {0} should not exit directly from state {1}, should go to {2} state first in {3}", | 255 | // "[ENTITY TRANSFER STATE MACHINE]: Agent with ID {0} should not exit directly from state {1}, should go to {2} state first in {3}", |
256 | id, state, AgentTransferState.CleaningUp, m_mod.Scene.RegionInfo.RegionName); | 256 | // id, state, AgentTransferState.CleaningUp, m_mod.Scene.RegionInfo.RegionName); |
257 | 257 | ||
258 | // throw new Exception( | 258 | // throw new Exception( |
259 | // "Agent with ID {0} cannot exit directly from state {1}, it must go to {2} state first", | 259 | // "Agent with ID {0} cannot exit directly from state {1}, it must go to {2} state first", |
260 | // state, AgentTransferState.CleaningUp); | 260 | // state, AgentTransferState.CleaningUp); |
261 | } | 261 | // } |
262 | 262 | ||
263 | m_agentsInTransit.Remove(id); | 263 | m_agentsInTransit.Remove(id); |
264 | 264 | ||
265 | m_log.DebugFormat( | 265 | // m_log.DebugFormat( |
266 | "[ENTITY TRANSFER STATE MACHINE]: Agent {0} cleared from transit in {1}", | 266 | // "[ENTITY TRANSFER STATE MACHINE]: Agent {0} cleared from transit in {1}", |
267 | id, m_mod.Scene.RegionInfo.RegionName); | 267 | // id, m_mod.Scene.RegionInfo.RegionName); |
268 | 268 | ||
269 | return true; | 269 | return true; |
270 | } | 270 | } |
271 | } | 271 | } |
272 | 272 | ||
273 | m_log.WarnFormat( | 273 | // m_log.WarnFormat( |
274 | "[ENTITY TRANSFER STATE MACHINE]: Agent {0} requested to clear from transit in {1} but was already cleared", | 274 | // "[ENTITY TRANSFER STATE MACHINE]: Agent {0} requested to clear from transit in {1} but was already cleared", |
275 | id, m_mod.Scene.RegionInfo.RegionName); | 275 | // id, m_mod.Scene.RegionInfo.RegionName); |
276 | 276 | ||
277 | return false; | 277 | return false; |
278 | } | 278 | } |