From 4c7ddd2c71c5189d7045c63a7a421d8742d8fcd4 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 19 Sep 2008 18:50:19 +0000 Subject: * Remove one possible deadlock situation as seen today * On script rez, XEngine was taking an m_scripts lock and then later on an m_parts lock when looking for a part by local id * In the meantime, a scene object being deleted would take an m_parts lock and then later on try to take an m_scripts lock when it tried to trigger script removal * There may be better ways to resolve this, but I believe that in general, we must always take an m_parts lock before an m_scripts lock --- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 466a879..7255de4 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -406,9 +406,15 @@ namespace OpenSim.Region.ScriptEngine.XEngine // Get the asset ID of the script, so we can check if we // already have it. + // We must look for the part outside the m_Scripts lock because GetSceneObjectPart later triggers the + // m_parts lock on SOG. At the same time, a scene object that is being deleted will take the m_parts lock + // and then later on try to take the m_scripts lock in this class when it calls OnRemoveScript() SceneObjectPart part = m_Scene.GetSceneObjectPart(localID); if (part == null) + { + Log.Error("[Script] SceneObjectPart unavailable. Script NOT started."); return false; + } TaskInventoryItem item = part.GetInventoryItem(itemID); if (item == null) @@ -494,7 +500,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine m_DomainScripts[appDomain].Add(itemID); ScriptInstance instance = - new ScriptInstance(this,localID, + new ScriptInstance(this, part.LocalId, part.UUID, itemID, assetID, assembly, m_AppDomains[appDomain], part.ParentGroup.RootPart.Name, -- cgit v1.1