simply NotFoundLocationCache, comment out some debug messages
parent
722b7cfbb2
commit
c0eae1f8f9
|
@ -1537,8 +1537,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||||
|
|
||||||
public ScenePresence CrossAsync(ScenePresence agent, bool isFlying)
|
public ScenePresence CrossAsync(ScenePresence agent, bool isFlying)
|
||||||
{
|
{
|
||||||
uint x;
|
|
||||||
uint y;
|
|
||||||
Vector3 newpos;
|
Vector3 newpos;
|
||||||
EntityTransferContext ctx = new EntityTransferContext();
|
EntityTransferContext ctx = new EntityTransferContext();
|
||||||
string failureReason;
|
string failureReason;
|
||||||
|
@ -1814,7 +1812,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||||
// In any case
|
// In any case
|
||||||
agent.IsInTransit = false;
|
agent.IsInTransit = false;
|
||||||
|
|
||||||
m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Crossing agent {0} {1} completed.", agent.Firstname, agent.Lastname);
|
// m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Crossing agent {0} {1} completed.", agent.Firstname, agent.Lastname);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -2115,79 +2113,62 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||||
// contains that point. A conservitive estimate.
|
// contains that point. A conservitive estimate.
|
||||||
private class NotFoundLocationCache
|
private class NotFoundLocationCache
|
||||||
{
|
{
|
||||||
private struct NotFoundLocation
|
private Dictionary<ulong, DateTime> m_notFoundLocations = new Dictionary<ulong, DateTime>();
|
||||||
{
|
|
||||||
public double minX, maxX, minY, maxY;
|
|
||||||
public DateTime expireTime;
|
|
||||||
}
|
|
||||||
private List<NotFoundLocation> m_notFoundLocations = new List<NotFoundLocation>();
|
|
||||||
public NotFoundLocationCache()
|
public NotFoundLocationCache()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
// Add an area to the list of 'not found' places. The area is the snapped region
|
// just use normal regions handlers and sizes
|
||||||
// area around the added point.
|
|
||||||
public void Add(double pX, double pY)
|
public void Add(double pX, double pY)
|
||||||
{
|
{
|
||||||
|
ulong psh = (ulong)pX & 0xffffff00ul;
|
||||||
|
psh <<= 32;
|
||||||
|
psh |= (ulong)pY & 0xffffff00ul;
|
||||||
|
|
||||||
lock (m_notFoundLocations)
|
lock (m_notFoundLocations)
|
||||||
{
|
m_notFoundLocations[psh] = DateTime.Now + TimeSpan.FromSeconds(30);;
|
||||||
if (!LockedContains(pX, pY))
|
|
||||||
{
|
|
||||||
NotFoundLocation nfl = new NotFoundLocation();
|
|
||||||
// A not found location is not found for at least a whole region sized area
|
|
||||||
nfl.minX = pX - (pX % (double)Constants.RegionSize);
|
|
||||||
nfl.minY = pY - (pY % (double)Constants.RegionSize);
|
|
||||||
nfl.maxX = nfl.minX + (double)Constants.RegionSize;
|
|
||||||
nfl.maxY = nfl.minY + (double)Constants.RegionSize;
|
|
||||||
nfl.expireTime = DateTime.Now + TimeSpan.FromSeconds(30);
|
|
||||||
m_notFoundLocations.Add(nfl);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
// Test to see of this point is in any of the 'not found' areas.
|
// Test to see of this point is in any of the 'not found' areas.
|
||||||
// Return 'true' if the point is found inside the 'not found' areas.
|
// Return 'true' if the point is found inside the 'not found' areas.
|
||||||
public bool Contains(double pX, double pY)
|
public bool Contains(double pX, double pY)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
ulong psh = (ulong)pX & 0xffffff00ul;
|
||||||
|
psh <<= 32;
|
||||||
|
psh |= (ulong)pY & 0xffffff00ul;
|
||||||
|
|
||||||
lock (m_notFoundLocations)
|
lock (m_notFoundLocations)
|
||||||
ret = LockedContains(pX, pY);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
private bool LockedContains(double pX, double pY)
|
|
||||||
{
|
|
||||||
bool ret = false;
|
|
||||||
this.DoExpiration();
|
|
||||||
foreach (NotFoundLocation nfl in m_notFoundLocations)
|
|
||||||
{
|
{
|
||||||
if (pX >= nfl.minX && pX < nfl.maxX && pY >= nfl.minY && pY < nfl.maxY)
|
if(m_notFoundLocations.ContainsKey(psh))
|
||||||
{
|
{
|
||||||
ret = true;
|
if(m_notFoundLocations[psh] > DateTime.UtcNow)
|
||||||
break;
|
return true;
|
||||||
|
m_notFoundLocations.Remove(psh);
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DoExpiration()
|
private void DoExpiration()
|
||||||
{
|
{
|
||||||
List<NotFoundLocation> m_toRemove = null;
|
List<ulong> m_toRemove = new List<ulong>();;
|
||||||
DateTime now = DateTime.Now;
|
DateTime now = DateTime.UtcNow;
|
||||||
foreach (NotFoundLocation nfl in m_notFoundLocations)
|
lock (m_notFoundLocations)
|
||||||
{
|
{
|
||||||
if (nfl.expireTime < now)
|
foreach (KeyValuePair<ulong, DateTime> kvp in m_notFoundLocations)
|
||||||
{
|
{
|
||||||
if (m_toRemove == null)
|
if (kvp.Value < now)
|
||||||
m_toRemove = new List<NotFoundLocation>();
|
m_toRemove.Add(kvp.Key);
|
||||||
m_toRemove.Add(nfl);
|
}
|
||||||
|
|
||||||
|
if (m_toRemove.Count > 0)
|
||||||
|
{
|
||||||
|
foreach (ulong u in m_toRemove)
|
||||||
|
m_notFoundLocations.Remove(u);
|
||||||
|
m_toRemove.Clear();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (m_toRemove != null)
|
|
||||||
{
|
|
||||||
foreach (NotFoundLocation nfl in m_toRemove)
|
|
||||||
m_notFoundLocations.Remove(nfl);
|
|
||||||
m_toRemove.Clear();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion // NotFoundLocationCache class
|
#endregion // NotFoundLocationCache class
|
||||||
private NotFoundLocationCache m_notFoundLocationCache = new NotFoundLocationCache();
|
private NotFoundLocationCache m_notFoundLocationCache = new NotFoundLocationCache();
|
||||||
|
|
||||||
|
@ -2202,7 +2183,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||||
|
|
||||||
// Given a world position, get the GridRegion info for
|
// Given a world position, get the GridRegion info for
|
||||||
// the region containing that point.
|
// the region containing that point.
|
||||||
// Someday this should be a method on GridService.
|
// Not needed on 0.9 grids
|
||||||
// 'pSizeHint' is the size of the source region but since the destination point can be anywhere
|
// 'pSizeHint' is the size of the source region but since the destination point can be anywhere
|
||||||
// the size of the target region is unknown thus the search area might have to be very large.
|
// the size of the target region is unknown thus the search area might have to be very large.
|
||||||
// Return 'null' if no such region exists.
|
// Return 'null' if no such region exists.
|
||||||
|
@ -2233,8 +2214,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||||
ret = pGridService.GetRegionByPosition(pScopeID, (int)possibleX, (int)possibleY);
|
ret = pGridService.GetRegionByPosition(pScopeID, (int)possibleX, (int)possibleY);
|
||||||
if (ret != null)
|
if (ret != null)
|
||||||
{
|
{
|
||||||
m_log.DebugFormat("{0} GetRegionContainingWorldLocation: Found region using legacy size. rloc=<{1},{2}>. Rname={3}",
|
// m_log.DebugFormat("{0} GetRegionContainingWorldLocation: Found region using legacy size. rloc=<{1},{2}>. Rname={3}",
|
||||||
LogHeader, possibleX, possibleY, ret.RegionName);
|
// LogHeader, possibleX, possibleY, ret.RegionName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret == null)
|
if (ret == null)
|
||||||
|
@ -2248,21 +2229,21 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||||
List<GridRegion> possibleRegions = pGridService.GetRegionRange(pScopeID,
|
List<GridRegion> possibleRegions = pGridService.GetRegionRange(pScopeID,
|
||||||
(int)(px - range), (int)(px),
|
(int)(px - range), (int)(px),
|
||||||
(int)(py - range), (int)(py));
|
(int)(py - range), (int)(py));
|
||||||
m_log.DebugFormat("{0} GetRegionContainingWorldLocation: possibleRegions cnt={1}, range={2}",
|
// m_log.DebugFormat("{0} GetRegionContainingWorldLocation: possibleRegions cnt={1}, range={2}",
|
||||||
LogHeader, possibleRegions.Count, range);
|
// LogHeader, possibleRegions.Count, range);
|
||||||
if (possibleRegions != null && possibleRegions.Count > 0)
|
if (possibleRegions != null && possibleRegions.Count > 0)
|
||||||
{
|
{
|
||||||
// If we found some regions, check to see if the point is within
|
// If we found some regions, check to see if the point is within
|
||||||
foreach (GridRegion gr in possibleRegions)
|
foreach (GridRegion gr in possibleRegions)
|
||||||
{
|
{
|
||||||
m_log.DebugFormat("{0} GetRegionContainingWorldLocation: possibleRegion nm={1}, regionLoc=<{2},{3}>, regionSize=<{4},{5}>",
|
// m_log.DebugFormat("{0} GetRegionContainingWorldLocation: possibleRegion nm={1}, regionLoc=<{2},{3}>, regionSize=<{4},{5}>",
|
||||||
LogHeader, gr.RegionName, gr.RegionLocX, gr.RegionLocY, gr.RegionSizeX, gr.RegionSizeY);
|
// LogHeader, gr.RegionName, gr.RegionLocX, gr.RegionLocY, gr.RegionSizeX, gr.RegionSizeY);
|
||||||
if (px >= (double)gr.RegionLocX && px < (double)(gr.RegionLocX + gr.RegionSizeX)
|
if (px >= (double)gr.RegionLocX && px < (double)(gr.RegionLocX + gr.RegionSizeX)
|
||||||
&& py >= (double)gr.RegionLocY && py < (double)(gr.RegionLocY + gr.RegionSizeY))
|
&& py >= (double)gr.RegionLocY && py < (double)(gr.RegionLocY + gr.RegionSizeY))
|
||||||
{
|
{
|
||||||
// Found a region that contains the point
|
// Found a region that contains the point
|
||||||
ret = gr;
|
ret = gr;
|
||||||
m_log.DebugFormat("{0} GetRegionContainingWorldLocation: found. RegionName={1}", LogHeader, ret.RegionName);
|
// m_log.DebugFormat("{0} GetRegionContainingWorldLocation: found. RegionName={1}", LogHeader, ret.RegionName);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2276,7 +2257,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||||
{
|
{
|
||||||
// remember this location was not found so we can quickly not find it next time
|
// remember this location was not found so we can quickly not find it next time
|
||||||
m_notFoundLocationCache.Add(px, py);
|
m_notFoundLocationCache.Add(px, py);
|
||||||
m_log.DebugFormat("{0} GetRegionContainingWorldLocation: Not found. Remembering loc=<{1},{2}>", LogHeader, px, py);
|
// m_log.DebugFormat("{0} GetRegionContainingWorldLocation: Not found. Remembering loc=<{1},{2}>", LogHeader, px, py);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -101,7 +101,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||||
/// <returns>true if the agent was not already in transit, false if it was</returns>
|
/// <returns>true if the agent was not already in transit, false if it was</returns>
|
||||||
internal bool SetInTransit(UUID id)
|
internal bool SetInTransit(UUID id)
|
||||||
{
|
{
|
||||||
m_log.DebugFormat("{0} SetInTransit. agent={1}, newState=Preparing", LogHeader, id);
|
// m_log.DebugFormat("{0} SetInTransit. agent={1}, newState=Preparing", LogHeader, id);
|
||||||
lock (m_agentsInTransit)
|
lock (m_agentsInTransit)
|
||||||
{
|
{
|
||||||
if (!m_agentsInTransit.ContainsKey(id))
|
if (!m_agentsInTransit.ContainsKey(id))
|
||||||
|
@ -123,7 +123,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||||
/// <exception cref='Exception'>Illegal transitions will throw an Exception</exception>
|
/// <exception cref='Exception'>Illegal transitions will throw an Exception</exception>
|
||||||
internal bool UpdateInTransit(UUID id, AgentTransferState newState)
|
internal bool UpdateInTransit(UUID id, AgentTransferState newState)
|
||||||
{
|
{
|
||||||
m_log.DebugFormat("{0} UpdateInTransit. agent={1}, newState={2}", LogHeader, id, newState);
|
// m_log.DebugFormat("{0} UpdateInTransit. agent={1}, newState={2}", LogHeader, id, newState);
|
||||||
|
|
||||||
bool transitionOkay = false;
|
bool transitionOkay = false;
|
||||||
|
|
||||||
|
@ -247,32 +247,32 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||||
{
|
{
|
||||||
AgentTransferState state = m_agentsInTransit[id];
|
AgentTransferState state = m_agentsInTransit[id];
|
||||||
|
|
||||||
if (state == AgentTransferState.Transferring || state == AgentTransferState.ReceivedAtDestination)
|
// if (state == AgentTransferState.Transferring || state == AgentTransferState.ReceivedAtDestination)
|
||||||
{
|
// {
|
||||||
// FIXME: For now, we allow exit from any state since a thrown exception in teleport is now guranteed
|
// FIXME: For now, we allow exit from any state since a thrown exception in teleport is now guranteed
|
||||||
// to be handled properly - ResetFromTransit() could be invoked at any step along the process
|
// to be handled properly - ResetFromTransit() could be invoked at any step along the process
|
||||||
m_log.WarnFormat(
|
// m_log.WarnFormat(
|
||||||
"[ENTITY TRANSFER STATE MACHINE]: Agent with ID {0} should not exit directly from state {1}, should go to {2} state first in {3}",
|
// "[ENTITY TRANSFER STATE MACHINE]: Agent with ID {0} should not exit directly from state {1}, should go to {2} state first in {3}",
|
||||||
id, state, AgentTransferState.CleaningUp, m_mod.Scene.RegionInfo.RegionName);
|
// id, state, AgentTransferState.CleaningUp, m_mod.Scene.RegionInfo.RegionName);
|
||||||
|
|
||||||
// throw new Exception(
|
// throw new Exception(
|
||||||
// "Agent with ID {0} cannot exit directly from state {1}, it must go to {2} state first",
|
// "Agent with ID {0} cannot exit directly from state {1}, it must go to {2} state first",
|
||||||
// state, AgentTransferState.CleaningUp);
|
// state, AgentTransferState.CleaningUp);
|
||||||
}
|
// }
|
||||||
|
|
||||||
m_agentsInTransit.Remove(id);
|
m_agentsInTransit.Remove(id);
|
||||||
|
|
||||||
m_log.DebugFormat(
|
// m_log.DebugFormat(
|
||||||
"[ENTITY TRANSFER STATE MACHINE]: Agent {0} cleared from transit in {1}",
|
// "[ENTITY TRANSFER STATE MACHINE]: Agent {0} cleared from transit in {1}",
|
||||||
id, m_mod.Scene.RegionInfo.RegionName);
|
// id, m_mod.Scene.RegionInfo.RegionName);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_log.WarnFormat(
|
// m_log.WarnFormat(
|
||||||
"[ENTITY TRANSFER STATE MACHINE]: Agent {0} requested to clear from transit in {1} but was already cleared",
|
// "[ENTITY TRANSFER STATE MACHINE]: Agent {0} requested to clear from transit in {1} but was already cleared",
|
||||||
id, m_mod.Scene.RegionInfo.RegionName);
|
// id, m_mod.Scene.RegionInfo.RegionName);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue