From b01c79354c4c9ca4e0f01fc4fef3ad4fb97f1c19 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Thu, 15 Mar 2012 00:20:47 +0000 Subject: [PATCH] Fix a problem where multiple near simultaneous calls to llDie() from multiple scripts in the same linkset can cause unnecessary thread aborts. The first llDie() could lock Scene.m_deleting_scene_object. The second llDie() would then wait at this lock. The first llDie() would go on to remove the second script but always abort it since the second script's WorkItem would not go away. Easiest solution here is to remove the m_deleting_scene_object since it's no longer justified - we no longer lock m_parts but take a copy instead. This also requires an adjustment in XEngine.OnRemoveScript not to use instance.ObjectID instead when firing the OnObjectRemoved event. --- OpenSim/Region/Framework/Scenes/Scene.cs | 11 +---------- .../Region/ScriptEngine/XEngine/XEngine.cs | 19 +++++++++---------- 2 files changed, 10 insertions(+), 20 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index a6f92500b0..0efcf72366 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -219,8 +219,6 @@ namespace OpenSim.Region.Framework.Scenes private int m_lastUpdate; private bool m_firstHeartbeat = true; - - private object m_deleting_scene_object = new object(); private UpdatePrioritizationSchemes m_priorityScheme = UpdatePrioritizationSchemes.Time; private bool m_reprioritizationEnabled = true; @@ -2006,15 +2004,8 @@ namespace OpenSim.Region.Framework.Scenes public void DeleteSceneObject(SceneObjectGroup group, bool silent) { // m_log.DebugFormat("[SCENE]: Deleting scene object {0} {1}", group.Name, group.UUID); - - //SceneObjectPart rootPart = group.GetChildPart(group.UUID); - // Serialise calls to RemoveScriptInstances to avoid - // deadlocking on m_parts inside SceneObjectGroup - lock (m_deleting_scene_object) - { - group.RemoveScriptInstances(true); - } + group.RemoveScriptInstances(true); SceneObjectPart[] partList = group.Parts; diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 5095037b03..e776f5ab8c 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -176,12 +176,16 @@ namespace OpenSim.Region.ScriptEngine.XEngine get { return m_ConfigSource; } } + /// + /// Event fired after the script engine has finished removing a script. + /// public event ScriptRemoved OnScriptRemoved; + + /// + /// Event fired after the script engine has finished removing a script from an object. + /// public event ObjectRemoved OnObjectRemoved; - // - // IRegionModule functions - // public void Initialise(IConfigSource configSource) { if (configSource.Configs["XEngine"] == null) @@ -1122,7 +1126,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine // Give the script some time to finish processing its last event. Simply aborting the script thread can // cause issues on mono 2.6, 2.10 and possibly later where locks are not released properly on abort. instance.Stop(1000); - + // bool objectRemoved = false; lock (m_PrimObjects) @@ -1153,14 +1157,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine UnloadAppDomain(instance.AppDomain); } - instance = null; - ObjectRemoved handlerObjectRemoved = OnObjectRemoved; if (handlerObjectRemoved != null) - { - SceneObjectPart part = m_Scene.GetSceneObjectPart(localID); - handlerObjectRemoved(part.UUID); - } + handlerObjectRemoved(instance.ObjectID); ScriptRemoved handlerScriptRemoved = OnScriptRemoved; if (handlerScriptRemoved != null)