diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs index 0cadd83e62..801af442e5 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs @@ -385,7 +385,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory /// public void QueueAppearanceSend(UUID agentid) { - // m_log.WarnFormat("[AVFACTORY]: Queue appearance send for {0}", agentid); +// m_log.DebugFormat("[AVFACTORY]: Queue appearance send for {0}", agentid); // 10000 ticks per millisecond, 1000 milliseconds per second long timestamp = DateTime.Now.Ticks + Convert.ToInt64(m_sendtime * 1000 * 10000); @@ -444,10 +444,17 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory Dictionary sends = new Dictionary(m_sendqueue); foreach (KeyValuePair kvp in sends) { - if (kvp.Value < now) + // We have to load the key and value into local parameters to avoid a race condition if we loop + // around and load kvp with a different value before FireAndForget has launched its thread. + UUID avatarID = kvp.Key; + long sendTime = kvp.Value; + +// m_log.DebugFormat("[AVFACTORY]: Handling queued appearance updates for {0}, update delta to now is {1}", avatarID, sendTime - now); + + if (sendTime < now) { - Util.FireAndForget(delegate(object o) { SendAppearance(kvp.Key); }); - m_sendqueue.Remove(kvp.Key); + Util.FireAndForget(o => SendAppearance(avatarID)); + m_sendqueue.Remove(avatarID); } } } @@ -457,10 +464,15 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory Dictionary saves = new Dictionary(m_savequeue); foreach (KeyValuePair kvp in saves) { - if (kvp.Value < now) + // We have to load the key and value into local parameters to avoid a race condition if we loop + // around and load kvp with a different value before FireAndForget has launched its thread. + UUID avatarID = kvp.Key; + long sendTime = kvp.Value; + + if (sendTime < now) { - Util.FireAndForget(delegate(object o) { SaveAppearance(kvp.Key); }); - m_savequeue.Remove(kvp.Key); + Util.FireAndForget(o => SaveAppearance(avatarID)); + m_savequeue.Remove(avatarID); } } } @@ -535,6 +547,8 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory public bool SendAppearance(UUID agentId) { +// m_log.DebugFormat("[AVFACTORY]: Sending appearance for {0}", agentId); + ScenePresence sp = m_scene.GetScenePresence(agentId); if (sp == null) { diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 2a18046591..e37cd33292 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2610,7 +2610,8 @@ namespace OpenSim.Region.Framework.Scenes /// public void SendAppearanceToAllOtherAgents() { - //m_log.DebugFormat("[SCENE PRESENCE] SendAppearanceToAllOtherAgents: {0} ({1})", Name, UUID); +// m_log.DebugFormat("[SCENE PRESENCE] SendAppearanceToAllOtherAgents: {0} {1}", Name, UUID); + // only send update from root agents to other clients; children are only "listening posts" if (IsChildAgent) { @@ -2638,7 +2639,7 @@ namespace OpenSim.Region.Framework.Scenes /// public void SendOtherAgentsAppearanceToMe() { - //m_log.DebugFormat("[SCENE PRESENCE] SendOtherAgentsAppearanceToMe: {0} ({1})", Name, UUID); +// m_log.DebugFormat("[SCENE PRESENCE] SendOtherAgentsAppearanceToMe: {0} {1}", Name, UUID); int count = 0; m_scene.ForEachRootScenePresence(delegate(ScenePresence scenePresence)