mirror of
https://github.com/opensim/opensim.git
synced 2026-08-01 06:06:06 +08:00
Avoid deadlock in NPCModule between DeleteNPC and GetNPC on m_avatars
Signed-off-by: BlueWall <jamesh@bluewallgroup.com>
This commit is contained in:
@@ -398,27 +398,31 @@ namespace OpenSim.Region.OptionalModules.World.NPC
|
||||
|
||||
public bool DeleteNPC(UUID agentID, Scene scene)
|
||||
{
|
||||
bool doRemove = false;
|
||||
NPCAvatar av;
|
||||
lock (m_avatars)
|
||||
{
|
||||
NPCAvatar av;
|
||||
if (m_avatars.TryGetValue(agentID, out av))
|
||||
{
|
||||
/*
|
||||
m_log.DebugFormat("[NPC MODULE]: Found {0} {1} to remove",
|
||||
agentID, av.Name);
|
||||
*/
|
||||
|
||||
scene.CloseAgent(agentID, false);
|
||||
|
||||
m_avatars.Remove(agentID);
|
||||
|
||||
/*
|
||||
m_log.DebugFormat("[NPC MODULE]: Removed NPC {0} {1}",
|
||||
agentID, av.Name);
|
||||
*/
|
||||
return true;
|
||||
doRemove = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (doRemove)
|
||||
{
|
||||
scene.CloseAgent(agentID, false);
|
||||
lock (m_avatars)
|
||||
{
|
||||
m_avatars.Remove(agentID);
|
||||
}
|
||||
m_log.DebugFormat("[NPC MODULE]: Removed NPC {0} {1}",
|
||||
agentID, av.Name);
|
||||
return true;
|
||||
}
|
||||
/*
|
||||
m_log.DebugFormat("[NPC MODULE]: Could not find {0} to remove",
|
||||
agentID);
|
||||
@@ -457,4 +461,4 @@ namespace OpenSim.Region.OptionalModules.World.NPC
|
||||
av.OwnerID == callerID || av.AgentId == callerID;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user