aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules/World
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2012-02-03 23:04:26 +0000
committerJustin Clark-Casey (justincc)2012-02-03 23:04:26 +0000
commitce34b359ad0254b6b4f460e2740e1a1ed30c456b (patch)
treede8031f3cc707d9ae910f7f41c62bc823f4c7a22 /OpenSim/Region/OptionalModules/World
parentRefactor common deserialization processor code to generic method ExternalRepr... (diff)
downloadopensim-SC_OLD-ce34b359ad0254b6b4f460e2740e1a1ed30c456b.zip
opensim-SC_OLD-ce34b359ad0254b6b4f460e2740e1a1ed30c456b.tar.gz
opensim-SC_OLD-ce34b359ad0254b6b4f460e2740e1a1ed30c456b.tar.bz2
opensim-SC_OLD-ce34b359ad0254b6b4f460e2740e1a1ed30c456b.tar.xz
Extend m_avatars lock in NpcModule.CreateNPC over both creation of NPC scene presence and population of m_avatars.
This is required to stop a race where the SensorRepeat module can detect an NPC avatar before m_avatars is populated. Extending the lock is the easiest to understand solution rather than getting complicated with null checks. Hopefully resolves http://opensimulator.org/mantis/view.php?id=5872
Diffstat (limited to 'OpenSim/Region/OptionalModules/World')
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs30
1 files changed, 16 insertions, 14 deletions
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
index 3831d7a..6a48b89 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
@@ -140,24 +140,26 @@ namespace OpenSim.Region.OptionalModules.World.NPC
140// acd.AgentID, i, acd.Appearance.Texture.FaceTextures[i]); 140// acd.AgentID, i, acd.Appearance.Texture.FaceTextures[i]);
141// } 141// }
142 142
143 scene.AuthenticateHandler.AddNewCircuit(npcAvatar.CircuitCode, acd); 143 lock (m_avatars)
144 scene.AddNewClient(npcAvatar, PresenceType.Npc);
145
146 ScenePresence sp;
147 if (scene.TryGetScenePresence(npcAvatar.AgentId, out sp))
148 { 144 {
149 m_log.DebugFormat( 145 scene.AuthenticateHandler.AddNewCircuit(npcAvatar.CircuitCode, acd);
150 "[NPC MODULE]: Successfully retrieved scene presence for NPC {0} {1}", sp.Name, sp.UUID); 146 scene.AddNewClient(npcAvatar, PresenceType.Npc);
151 147
152 sp.CompleteMovement(npcAvatar, false); 148 ScenePresence sp;
153 } 149 if (scene.TryGetScenePresence(npcAvatar.AgentId, out sp))
154 else 150 {
155 { 151 m_log.DebugFormat(
156 m_log.WarnFormat("[NPC MODULE]: Could not find scene presence for NPC {0} {1}", sp.Name, sp.UUID); 152 "[NPC MODULE]: Successfully retrieved scene presence for NPC {0} {1}", sp.Name, sp.UUID);
157 } 153
154 sp.CompleteMovement(npcAvatar, false);
155 }
156 else
157 {
158 m_log.WarnFormat("[NPC MODULE]: Could not find scene presence for NPC {0} {1}", sp.Name, sp.UUID);
159 }
158 160
159 lock (m_avatars)
160 m_avatars.Add(npcAvatar.AgentId, npcAvatar); 161 m_avatars.Add(npcAvatar.AgentId, npcAvatar);
162 }
161 163
162 m_log.DebugFormat("[NPC MODULE]: Created NPC with id {0}", npcAvatar.AgentId); 164 m_log.DebugFormat("[NPC MODULE]: Created NPC with id {0}", npcAvatar.AgentId);
163 165