Fix a problem where llDie() calls were sometimes leaving dead objects behind.

When an object was deleted, the remove script instance call was aggregating the scripting events as normal.
This would queue a full update of the prim before the viewer was notifed of the deletion of that prim (QuitPacket)
On some occasions, the QuitPacket would be sent before the full update was dequeued and sent.
In principle, you would think that a viewer would ignore updates for deleted prims.  But it appears that in the Linden viewer (1.23.5),
a prim update that arrives after the prim was deleted instead makes the deleted prim persist in the viewer.  Such prims have no properties
and cannot be removed from the viewer except by a relog.
This change stops the prim event aggregation call if it's being deleted anyway, hence removing the spurious viewer-confusing update.
mysql-performance
Justin Clark-Casey (justincc) 2010-01-25 21:51:58 +00:00
parent 19d4867af7
commit 38cfc9366c
8 changed files with 73 additions and 19 deletions

View File

@ -1465,6 +1465,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
public void SendKillObject(ulong regionHandle, uint localID) public void SendKillObject(ulong regionHandle, uint localID)
{ {
// m_log.DebugFormat("[CLIENT]: Sending KillObjectPacket to {0} for {1} in {2}", Name, localID, regionHandle);
KillObjectPacket kill = (KillObjectPacket)PacketPool.Instance.GetPacket(PacketType.KillObject); KillObjectPacket kill = (KillObjectPacket)PacketPool.Instance.GetPacket(PacketType.KillObject);
// TODO: don't create new blocks if recycling an old packet // TODO: don't create new blocks if recycling an old packet
kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1]; kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1];
@ -3472,6 +3474,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
public void SendPrimitiveToClient(SendPrimitiveData data) public void SendPrimitiveToClient(SendPrimitiveData data)
{ {
// string text = data.text;
// if (text.IndexOf("\n") >= 0)
// text = text.Remove(text.IndexOf("\n"));
// m_log.DebugFormat(
// "[CLIENT]: Placing request to send full info about prim {0} text {1} to client {2}",
// data.localID, text, Name);
if (data.priority == double.NaN) if (data.priority == double.NaN)
{ {
m_log.Error("[LLClientView] SendPrimitiveToClient received a NaN priority, dropping update"); m_log.Error("[LLClientView] SendPrimitiveToClient received a NaN priority, dropping update");
@ -3509,7 +3518,16 @@ namespace OpenSim.Region.ClientStack.LindenUDP
outPacket.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[count]; outPacket.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[count];
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{
outPacket.ObjectData[i] = m_primFullUpdates.Dequeue(); outPacket.ObjectData[i] = m_primFullUpdates.Dequeue();
// string text = Util.FieldToString(outPacket.ObjectData[i].Text);
// if (text.IndexOf("\n") >= 0)
// text = text.Remove(text.IndexOf("\n"));
// m_log.DebugFormat(
// "[CLIENT]: Sending full info about prim {0} text {1} to client {2}",
// outPacket.ObjectData[i].ID, text, Name);
}
} }
OutPacket(outPacket, ThrottleOutPacketType.State); OutPacket(outPacket, ThrottleOutPacketType.State);

View File

@ -77,7 +77,11 @@ namespace OpenSim.Region.Framework.Interfaces
/// <summary> /// <summary>
/// Stop all the scripts in this entity. /// Stop all the scripts in this entity.
/// </summary> /// </summary>
void RemoveScriptInstances(); /// <param name="sceneObjectBeingDeleted">
/// Should be true if these scripts are being removed because the scene
/// object is being deleted. This will prevent spurious updates to the client.
/// </param>
void RemoveScriptInstances(bool sceneObjectBeingDeleted);
/// <summary> /// <summary>
/// Start a script which is in this entity's inventory. /// Start a script which is in this entity's inventory.
@ -103,7 +107,11 @@ namespace OpenSim.Region.Framework.Interfaces
/// Stop a script which is in this prim's inventory. /// Stop a script which is in this prim's inventory.
/// </summary> /// </summary>
/// <param name="itemId"></param> /// <param name="itemId"></param>
void RemoveScriptInstance(UUID itemId); /// <param name="sceneObjectBeingDeleted">
/// Should be true if these scripts are being removed because the scene
/// object is being deleted. This will prevent spurious updates to the client.
/// </param>
void RemoveScriptInstance(UUID itemId, bool sceneObjectBeingDeleted);
/// <summary> /// <summary>
/// Add an item to this entity's inventory. If an item with the same name already exists, then an alternative /// Add an item to this entity's inventory. If an item with the same name already exists, then an alternative

View File

@ -256,7 +256,7 @@ namespace OpenSim.Region.Framework.Scenes
if (isScriptRunning) if (isScriptRunning)
{ {
part.Inventory.RemoveScriptInstance(item.ItemID); part.Inventory.RemoveScriptInstance(item.ItemID, false);
} }
// Update item with new asset // Update item with new asset
@ -855,8 +855,10 @@ namespace OpenSim.Region.Framework.Scenes
if (item.Type == 10) if (item.Type == 10)
{ {
part.RemoveScriptEvents(itemID);
EventManager.TriggerRemoveScript(localID, itemID); EventManager.TriggerRemoveScript(localID, itemID);
} }
group.RemoveInventoryItem(localID, itemID); group.RemoveInventoryItem(localID, itemID);
part.GetProperties(remoteClient); part.GetProperties(remoteClient);
} }

View File

@ -1009,7 +1009,7 @@ namespace OpenSim.Region.Framework.Scenes
{ {
if (ent is SceneObjectGroup) if (ent is SceneObjectGroup)
{ {
((SceneObjectGroup) ent).RemoveScriptInstances(); ((SceneObjectGroup) ent).RemoveScriptInstances(false);
} }
} }
} }
@ -1884,13 +1884,15 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="silent">Suppress broadcasting changes to other clients.</param> /// <param name="silent">Suppress broadcasting changes to other clients.</param>
public void DeleteSceneObject(SceneObjectGroup group, bool silent) 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); //SceneObjectPart rootPart = group.GetChildPart(group.UUID);
// Serialise calls to RemoveScriptInstances to avoid // Serialise calls to RemoveScriptInstances to avoid
// deadlocking on m_parts inside SceneObjectGroup // deadlocking on m_parts inside SceneObjectGroup
lock (m_deleting_scene_object) lock (m_deleting_scene_object)
{ {
group.RemoveScriptInstances(); group.RemoveScriptInstances(true);
} }
foreach (SceneObjectPart part in group.Children.Values) foreach (SceneObjectPart part in group.Children.Values)
@ -1918,6 +1920,8 @@ namespace OpenSim.Region.Framework.Scenes
} }
group.DeleteGroup(silent); group.DeleteGroup(silent);
// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID);
} }
/// <summary> /// <summary>

View File

@ -74,13 +74,17 @@ namespace OpenSim.Region.Framework.Scenes
/// <summary> /// <summary>
/// Stop the scripts contained in all the prims in this group /// Stop the scripts contained in all the prims in this group
/// </summary> /// </summary>
public void RemoveScriptInstances() /// <param name="sceneObjectBeingDeleted">
/// Should be true if these scripts are being removed because the scene
/// object is being deleted. This will prevent spurious updates to the client.
/// </param>
public void RemoveScriptInstances(bool sceneObjectBeingDeleted)
{ {
lock (m_parts) lock (m_parts)
{ {
foreach (SceneObjectPart part in m_parts.Values) foreach (SceneObjectPart part in m_parts.Values)
{ {
part.Inventory.RemoveScriptInstances(); part.Inventory.RemoveScriptInstances(sceneObjectBeingDeleted);
} }
} }
} }

View File

@ -2479,7 +2479,7 @@ namespace OpenSim.Region.Framework.Scenes
//m_log.Debug("prev: " + prevflag.ToString() + " curr: " + Flags.ToString()); //m_log.Debug("prev: " + prevflag.ToString() + " curr: " + Flags.ToString());
//ScheduleFullUpdate(); //ScheduleFullUpdate();
} }
public void RemoveScriptEvents(UUID scriptid) public void RemoveScriptEvents(UUID scriptid)
{ {
lock (m_scriptEvents) lock (m_scriptEvents)
@ -2533,6 +2533,8 @@ namespace OpenSim.Region.Framework.Scenes
/// </summary> /// </summary>
public void ScheduleFullUpdate() public void ScheduleFullUpdate()
{ {
// m_log.DebugFormat("[SCENE OBJECT PART]: Scheduling full update for {0} {1}", Name, LocalId);
if (m_parentGroup != null) if (m_parentGroup != null)
{ {
m_parentGroup.QueueForUpdateCheck(); m_parentGroup.QueueForUpdateCheck();
@ -4042,6 +4044,8 @@ namespace OpenSim.Region.Framework.Scenes
if (m_parentGroup == null) if (m_parentGroup == null)
{ {
// m_log.DebugFormat(
// "[SCENE OBJECT PART]: Scheduling part {0} {1} for full update in aggregateScriptEvents() since m_parentGroup == null", Name, LocalId);
ScheduleFullUpdate(); ScheduleFullUpdate();
return; return;
} }
@ -4058,9 +4062,15 @@ namespace OpenSim.Region.Framework.Scenes
LocalFlags=(PrimFlags)objectflagupdate; LocalFlags=(PrimFlags)objectflagupdate;
if (m_parentGroup != null && m_parentGroup.RootPart == this) if (m_parentGroup != null && m_parentGroup.RootPart == this)
{
m_parentGroup.aggregateScriptEvents(); m_parentGroup.aggregateScriptEvents();
}
else else
{
// m_log.DebugFormat(
// "[SCENE OBJECT PART]: Scheduling part {0} {1} for full update in aggregateScriptEvents()", Name, LocalId);
ScheduleFullUpdate(); ScheduleFullUpdate();
}
} }
public int registerTargetWaypoint(Vector3 target, float tolerance) public int registerTargetWaypoint(Vector3 target, float tolerance)

View File

@ -230,7 +230,11 @@ namespace OpenSim.Region.Framework.Scenes
/// <summary> /// <summary>
/// Stop all the scripts in this prim. /// Stop all the scripts in this prim.
/// </summary> /// </summary>
public void RemoveScriptInstances() /// <param name="sceneObjectBeingDeleted">
/// Should be true if these scripts are being removed because the scene
/// object is being deleted. This will prevent spurious updates to the client.
/// </param>
public void RemoveScriptInstances(bool sceneObjectBeingDeleted)
{ {
lock (Items) lock (Items)
{ {
@ -238,8 +242,7 @@ namespace OpenSim.Region.Framework.Scenes
{ {
if ((int)InventoryType.LSL == item.InvType) if ((int)InventoryType.LSL == item.InvType)
{ {
RemoveScriptInstance(item.ItemID); RemoveScriptInstance(item.ItemID, sceneObjectBeingDeleted);
m_part.RemoveScriptEvents(item.ItemID);
} }
} }
} }
@ -388,10 +391,17 @@ namespace OpenSim.Region.Framework.Scenes
/// Stop a script which is in this prim's inventory. /// Stop a script which is in this prim's inventory.
/// </summary> /// </summary>
/// <param name="itemId"></param> /// <param name="itemId"></param>
public void RemoveScriptInstance(UUID itemId) /// <param name="sceneObjectBeingDeleted">
/// Should be true if this script is being removed because the scene
/// object is being deleted. This will prevent spurious updates to the client.
/// </param>
public void RemoveScriptInstance(UUID itemId, bool sceneObjectBeingDeleted)
{ {
if (m_items.ContainsKey(itemId)) if (m_items.ContainsKey(itemId))
{ {
if (!sceneObjectBeingDeleted)
m_part.RemoveScriptEvents(itemId);
m_part.ParentGroup.Scene.EventManager.TriggerRemoveScript(m_part.LocalId, itemId); m_part.ParentGroup.Scene.EventManager.TriggerRemoveScript(m_part.LocalId, itemId);
m_part.ParentGroup.AddActiveScriptCount(-1); m_part.ParentGroup.AddActiveScriptCount(-1);
} }
@ -465,7 +475,7 @@ namespace OpenSim.Region.Framework.Scenes
if (i.Name == item.Name) if (i.Name == item.Name)
{ {
if (i.InvType == (int)InventoryType.LSL) if (i.InvType == (int)InventoryType.LSL)
RemoveScriptInstance(i.ItemID); RemoveScriptInstance(i.ItemID, false);
RemoveInventoryItem(i.ItemID); RemoveInventoryItem(i.ItemID);
break; break;
@ -613,6 +623,7 @@ namespace OpenSim.Region.Framework.Scenes
int type = m_items[itemID].InvType; int type = m_items[itemID].InvType;
if (type == 10) // Script if (type == 10) // Script
{ {
m_part.RemoveScriptEvents(itemID);
m_part.ParentGroup.Scene.EventManager.TriggerRemoveScript(m_part.LocalId, itemID); m_part.ParentGroup.Scene.EventManager.TriggerRemoveScript(m_part.LocalId, itemID);
} }
m_items.Remove(itemID); m_items.Remove(itemID);

View File

@ -806,12 +806,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine
instance.ClearQueue(); instance.ClearQueue();
instance.Stop(0); instance.Stop(0);
SceneObjectPart part =
m_Scene.GetSceneObjectPart(localID);
if (part != null)
part.RemoveScriptEvents(itemID);
// bool objectRemoved = false; // bool objectRemoved = false;
lock (m_PrimObjects) lock (m_PrimObjects)
@ -846,7 +840,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine
ObjectRemoved handlerObjectRemoved = OnObjectRemoved; ObjectRemoved handlerObjectRemoved = OnObjectRemoved;
if (handlerObjectRemoved != null) if (handlerObjectRemoved != null)
{
SceneObjectPart part = m_Scene.GetSceneObjectPart(localID);
handlerObjectRemoved(part.UUID); handlerObjectRemoved(part.UUID);
}
CleanAssemblies(); CleanAssemblies();
} }