mirror of
https://github.com/opensim/opensim.git
synced 2026-08-06 17:32:42 +08:00
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
This commit is contained in:
@@ -140,24 +140,26 @@ namespace OpenSim.Region.OptionalModules.World.NPC
|
||||
// acd.AgentID, i, acd.Appearance.Texture.FaceTextures[i]);
|
||||
// }
|
||||
|
||||
scene.AuthenticateHandler.AddNewCircuit(npcAvatar.CircuitCode, acd);
|
||||
scene.AddNewClient(npcAvatar, PresenceType.Npc);
|
||||
|
||||
ScenePresence sp;
|
||||
if (scene.TryGetScenePresence(npcAvatar.AgentId, out sp))
|
||||
{
|
||||
m_log.DebugFormat(
|
||||
"[NPC MODULE]: Successfully retrieved scene presence for NPC {0} {1}", sp.Name, sp.UUID);
|
||||
|
||||
sp.CompleteMovement(npcAvatar, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.WarnFormat("[NPC MODULE]: Could not find scene presence for NPC {0} {1}", sp.Name, sp.UUID);
|
||||
}
|
||||
|
||||
lock (m_avatars)
|
||||
{
|
||||
scene.AuthenticateHandler.AddNewCircuit(npcAvatar.CircuitCode, acd);
|
||||
scene.AddNewClient(npcAvatar, PresenceType.Npc);
|
||||
|
||||
ScenePresence sp;
|
||||
if (scene.TryGetScenePresence(npcAvatar.AgentId, out sp))
|
||||
{
|
||||
m_log.DebugFormat(
|
||||
"[NPC MODULE]: Successfully retrieved scene presence for NPC {0} {1}", sp.Name, sp.UUID);
|
||||
|
||||
sp.CompleteMovement(npcAvatar, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.WarnFormat("[NPC MODULE]: Could not find scene presence for NPC {0} {1}", sp.Name, sp.UUID);
|
||||
}
|
||||
|
||||
m_avatars.Add(npcAvatar.AgentId, npcAvatar);
|
||||
}
|
||||
|
||||
m_log.DebugFormat("[NPC MODULE]: Created NPC with id {0}", npcAvatar.AgentId);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user