From 2f7539a25b859d3983ad78106d9cac78abda2b4d Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Wed, 14 May 2014 21:49:29 +0100 Subject: [PATCH] Remove a race where the client's SP.CompleteMovement() thread could attempt to restart attachment scripts before the source simulator's SP.UpdateAgent() thread had added them. This commit changes the order of code so that attachments are re-added before the CompleteMovement() thread is released. Relates to http://opensimulator.org/mantis/view.php?id=7148 --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 8c569758e0..6020a9ef7d 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3876,9 +3876,6 @@ namespace OpenSim.Region.Framework.Scenes private void CopyFrom(AgentData cAgent) { - lock (m_originRegionIDAccessLock) - m_originRegionID = cAgent.RegionID; - m_callbackURI = cAgent.CallbackURI; // m_log.DebugFormat( // "[SCENE PRESENCE]: Set callback for {0} in {1} to {2} in CopyFrom()", @@ -3951,6 +3948,12 @@ namespace OpenSim.Region.Framework.Scenes if (Scene.AttachmentsModule != null) Scene.AttachmentsModule.CopyAttachments(cAgent, this); + + // This must occur after attachments are copied, as it releases the CompleteMovement() calling thread + // originating from the client completing a teleport. Otherwise, CompleteMovement() code to restart + // script attachments can outrace this thread. + lock (m_originRegionIDAccessLock) + m_originRegionID = cAgent.RegionID; } public bool CopyAgent(out IAgentData agent)