diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 4583b52ad8..2418830223 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -343,6 +343,12 @@ namespace OpenSim.Region.Framework.Scenes
///
private object m_originRegionIDAccessLock = new object();
+ ///
+ /// Triggered on entity transfer after to allow CompleteMovement() to proceed after we have received an
+ /// UpdateAgent from the originating region.ddkjjkj
+ ///
+ private AutoResetEvent m_updateAgentReceivedAfterTransferEvent = new AutoResetEvent(false);
+
///
/// Used by the entity transfer module to signal when the presence should not be closed because a subsequent
/// teleport is reusing the connection.
@@ -1647,8 +1653,7 @@ namespace OpenSim.Region.Framework.Scenes
// For the moment, just set the size as passed.
PhysicsActor.Size = size;
// PhysicsActor.setAvatarSize(size, feetoffset);
- }
-
+ }
}
private bool WaitForUpdateAgent(IClientAPI client)
@@ -1657,20 +1662,12 @@ namespace OpenSim.Region.Framework.Scenes
// (which triggers Scene.IncomingUpdateChildAgent(AgentData cAgentData) here in the destination,
// m_originRegionID is UUID.Zero; after, it's non-Zero. The CompleteMovement sequence initiated from the
// viewer (in turn triggered by the source region sending it a TeleportFinish event) waits until it's non-zero
- int count = 50;
- UUID originID;
+ m_updateAgentReceivedAfterTransferEvent.WaitOne(10000);
+
+ UUID originID = UUID.Zero;
lock (m_originRegionIDAccessLock)
- originID = m_originRegionID;
-
- while (originID.Equals(UUID.Zero) && count-- > 0)
- {
- lock (m_originRegionIDAccessLock)
- originID = m_originRegionID;
-
- m_log.DebugFormat("[SCENE PRESENCE]: Agent {0} waiting for update in {1}", client.Name, Scene.Name);
- Thread.Sleep(200);
- }
+ originID = m_originRegionID;
if (originID.Equals(UUID.Zero))
{
@@ -3819,6 +3816,8 @@ namespace OpenSim.Region.Framework.Scenes
return;
CopyFrom(cAgentData);
+
+ m_updateAgentReceivedAfterTransferEvent.Set();
}
private static Vector3 marker = new Vector3(-1f, -1f, -1f);