Avoid deadlock in NPCModule between DeleteNPC and GetNPC on m_avatars

Signed-off-by: BlueWall <jamesh@bluewallgroup.com>
inv-download
tglion 2015-04-18 09:04:33 +02:00 committed by BlueWall
parent 28ce323802
commit b4347cf214
1 changed files with 16 additions and 12 deletions

View File

@ -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);