Addresses a race condition that happened between the viewer and the departing region wrt the creation of the child agent in the receiving region, and that resulted in failed TPs.

This commit is contained in:
diva
2009-02-04 16:31:48 +00:00
parent 8d6bd1b650
commit be3e676d33
2 changed files with 14 additions and 3 deletions

View File

@@ -2911,7 +2911,9 @@ namespace OpenSim.Region.Environment.Scenes
// m_log.DebugFormat(
// "[SCENE]: Incoming child agent update for {0} in {1}", cAgentData.AgentID, RegionInfo.RegionName);
ScenePresence childAgentUpdate = GetScenePresence(cAgentData.AgentID);
// We have to wait until the viewer contacts this region after receiving EAC.
// That calls AddNewClient, which finally creates the ScenePresence
ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID);
if (childAgentUpdate != null)
{
childAgentUpdate.ChildAgentDataUpdate(cAgentData);
@@ -2947,6 +2949,16 @@ namespace OpenSim.Region.Environment.Scenes
return false;
}
protected virtual ScenePresence WaitGetScenePresence(UUID agentID)
{
int ntimes = 10;
ScenePresence childAgentUpdate = null;
while ((childAgentUpdate = GetScenePresence(agentID)) == null && (ntimes-- > 0))
Thread.Sleep(1000);
return childAgentUpdate;
}
public virtual bool IncomingReleaseAgent(UUID id)
{
return m_sceneGridService.ReleaseAgent(id);

View File

@@ -1000,7 +1000,6 @@ namespace OpenSim.Region.Environment.Scenes
/// </summary>
public void CompleteMovement()
{
//Console.WriteLine("\n CompleteMovement \n");
Vector3 look = Velocity;
if ((look.X == 0) && (look.Y == 0) && (look.Z == 0))
{
@@ -1017,7 +1016,7 @@ namespace OpenSim.Region.Environment.Scenes
if ((m_callbackURI != null) && !m_callbackURI.Equals(""))
{
//m_log.DebugFormat("Found callback URI {0}", m_callbackURI);
m_log.DebugFormat("[SCENE PRESENCE]: Releasing agent in URI {0}", m_callbackURI);
Scene.SendReleaseAgent(m_rootRegionHandle, UUID, m_callbackURI);
m_callbackURI = null;
}