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.
0.7.3-post-fixes
Justin Clark-Casey (justincc) 2012-03-15 00:20:47 +00:00
parent 9ecbcb787c
commit b01c79354c
2 changed files with 10 additions and 20 deletions

View File

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

View File

@ -176,12 +176,16 @@ namespace OpenSim.Region.ScriptEngine.XEngine
get { return m_ConfigSource; }
}
/// <summary>
/// Event fired after the script engine has finished removing a script.
/// </summary>
public event ScriptRemoved OnScriptRemoved;
/// <summary>
/// Event fired after the script engine has finished removing a script from an object.
/// </summary>
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)