Merge branch 'master' of /home/opensim/var/repo/opensim

integration
BlueWall 2012-07-10 18:17:52 -04:00
commit 8a1b4d225b
11 changed files with 150 additions and 22 deletions

View File

@ -211,16 +211,20 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
lock (sp.AttachmentsSyncLock) lock (sp.AttachmentsSyncLock)
{ {
foreach (SceneObjectGroup grp in sp.GetAttachments()) foreach (SceneObjectGroup so in sp.GetAttachments())
{ {
grp.Scene.DeleteSceneObject(grp, false); // We can only remove the script instances from the script engine after we've retrieved their xml state
// when we update the attachment item.
m_scene.DeleteSceneObject(so, false, false);
if (saveChanged || saveAllScripted) if (saveChanged || saveAllScripted)
{ {
grp.IsAttachment = false; so.IsAttachment = false;
grp.AbsolutePosition = grp.RootPart.AttachedPos; so.AbsolutePosition = so.RootPart.AttachedPos;
UpdateKnownItem(sp, grp, saveAllScripted); UpdateKnownItem(sp, so, saveAllScripted);
} }
so.RemoveScriptInstances(true);
} }
sp.ClearAttachments(); sp.ClearAttachments();
@ -682,7 +686,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
m_scene.EventManager.TriggerOnAttach(so.LocalId, so.FromItemID, UUID.Zero); m_scene.EventManager.TriggerOnAttach(so.LocalId, so.FromItemID, UUID.Zero);
sp.RemoveAttachment(so); sp.RemoveAttachment(so);
m_scene.DeleteSceneObject(so, false);
// We can only remove the script instances from the script engine after we've retrieved their xml state
// when we update the attachment item.
m_scene.DeleteSceneObject(so, false, false);
// Prepare sog for storage // Prepare sog for storage
so.AttachedAvatar = UUID.Zero; so.AttachedAvatar = UUID.Zero;
@ -691,6 +698,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
so.AbsolutePosition = so.RootPart.AttachedPos; so.AbsolutePosition = so.RootPart.AttachedPos;
UpdateKnownItem(sp, so, true); UpdateKnownItem(sp, so, true);
so.RemoveScriptInstances(true);
} }
private SceneObjectGroup RezSingleAttachmentFromInventoryInternal( private SceneObjectGroup RezSingleAttachmentFromInventoryInternal(

View File

@ -92,7 +92,7 @@ namespace OpenSim.Region.Framework.Interfaces
void ResumeScripts(); void ResumeScripts();
/// <summary> /// <summary>
/// Stop all the scripts in this entity. /// Stop and remove all the scripts in this entity from the scene.
/// </summary> /// </summary>
/// <param name="sceneObjectBeingDeleted"> /// <param name="sceneObjectBeingDeleted">
/// Should be true if these scripts are being removed because the scene /// Should be true if these scripts are being removed because the scene
@ -100,6 +100,11 @@ namespace OpenSim.Region.Framework.Interfaces
/// </param> /// </param>
void RemoveScriptInstances(bool sceneObjectBeingDeleted); void RemoveScriptInstances(bool sceneObjectBeingDeleted);
/// <summary>
/// Stop all the scripts in this entity.
/// </summary>
void StopScriptInstances();
/// <summary> /// <summary>
/// Start a script which is in this entity's inventory. /// Start a script which is in this entity's inventory.
/// </summary> /// </summary>
@ -129,7 +134,7 @@ namespace OpenSim.Region.Framework.Interfaces
bool CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource); bool CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource);
/// <summary> /// <summary>
/// Stop a script which is in this prim's inventory. /// Stop and remove a script which is in this prim's inventory from the scene.
/// </summary> /// </summary>
/// <param name="itemId"></param> /// <param name="itemId"></param>
/// <param name="sceneObjectBeingDeleted"> /// <param name="sceneObjectBeingDeleted">
@ -138,6 +143,12 @@ namespace OpenSim.Region.Framework.Interfaces
/// </param> /// </param>
void RemoveScriptInstance(UUID itemId, bool sceneObjectBeingDeleted); void RemoveScriptInstance(UUID itemId, bool sceneObjectBeingDeleted);
/// <summary>
/// Stop a script which is in this prim's inventory.
/// </summary>
/// <param name="itemId"></param>
void StopScriptInstance(UUID itemId);
/// <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
/// name is chosen. /// name is chosen.

View File

@ -2183,13 +2183,30 @@ namespace OpenSim.Region.Framework.Scenes
/// <summary> /// <summary>
/// Synchronously delete the given object from the scene. /// Synchronously delete the given object from the scene.
/// </summary> /// </summary>
/// <remarks>
/// Scripts are also removed.
/// </remarks>
/// <param name="group">Object Id</param> /// <param name="group">Object Id</param>
/// <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)
{ {
DeleteSceneObject(group, silent, true);
}
/// <summary>
/// Synchronously delete the given object from the scene.
/// </summary>
/// <param name="group">Object Id</param>
/// <param name="silent">Suppress broadcasting changes to other clients.</param>
/// <param name="removeScripts">If true, then scripts are removed. If false, then they are only stopped.</para>
public void DeleteSceneObject(SceneObjectGroup group, bool silent, bool removeScripts)
{
// m_log.DebugFormat("[SCENE]: Deleting scene object {0} {1}", group.Name, group.UUID); // m_log.DebugFormat("[SCENE]: Deleting scene object {0} {1}", group.Name, group.UUID);
group.RemoveScriptInstances(true); if (removeScripts)
group.RemoveScriptInstances(true);
else
group.StopScriptInstances();
SceneObjectPart[] partList = group.Parts; SceneObjectPart[] partList = group.Parts;

View File

@ -79,7 +79,7 @@ namespace OpenSim.Region.Framework.Scenes
} }
/// <summary> /// <summary>
/// Stop the scripts contained in all the prims in this group /// Stop and remove the scripts contained in all the prims in this group
/// </summary> /// </summary>
/// <param name="sceneObjectBeingDeleted"> /// <param name="sceneObjectBeingDeleted">
/// Should be true if these scripts are being removed because the scene /// Should be true if these scripts are being removed because the scene
@ -92,6 +92,14 @@ namespace OpenSim.Region.Framework.Scenes
parts[i].Inventory.RemoveScriptInstances(sceneObjectBeingDeleted); parts[i].Inventory.RemoveScriptInstances(sceneObjectBeingDeleted);
} }
/// <summary>
/// Stop the scripts contained in all the prims in this group
/// </summary>
public void StopScriptInstances()
{
Array.ForEach<SceneObjectPart>(m_parts.GetArray(), p => p.Inventory.StopScriptInstances());
}
/// <summary> /// <summary>
/// Add an inventory item from a user's inventory to a prim in this scene object. /// Add an inventory item from a user's inventory to a prim in this scene object.
/// </summary> /// </summary>

View File

@ -4556,10 +4556,20 @@ namespace OpenSim.Region.Framework.Scenes
/// Get a copy of the list of sitting avatars. /// Get a copy of the list of sitting avatars.
/// </summary> /// </summary>
/// <remarks>This applies to all sitting avatars whether there is a sit target set or not.</remarks> /// <remarks>This applies to all sitting avatars whether there is a sit target set or not.</remarks>
/// <returns></returns> /// <returns>A hashset of the sitting avatars. Returns null if there are no sitting avatars.</returns>
public HashSet<UUID> GetSittingAvatars() public HashSet<UUID> GetSittingAvatars()
{ {
return new HashSet<UUID>(m_sittingAvatars); HashSet<UUID> sittingAvatars = m_sittingAvatars;
if (sittingAvatars == null)
{
return null;
}
else
{
lock (sittingAvatars)
return new HashSet<UUID>(sittingAvatars);
}
} }
/// <summary> /// <summary>

View File

@ -280,7 +280,7 @@ namespace OpenSim.Region.Framework.Scenes
} }
/// <summary> /// <summary>
/// Stop all the scripts in this prim. /// Stop and remove all the scripts in this prim.
/// </summary> /// </summary>
/// <param name="sceneObjectBeingDeleted"> /// <param name="sceneObjectBeingDeleted">
/// Should be true if these scripts are being removed because the scene /// Should be true if these scripts are being removed because the scene
@ -293,6 +293,14 @@ namespace OpenSim.Region.Framework.Scenes
RemoveScriptInstance(item.ItemID, sceneObjectBeingDeleted); RemoveScriptInstance(item.ItemID, sceneObjectBeingDeleted);
} }
/// <summary>
/// Stop all the scripts in this prim.
/// </summary>
public void StopScriptInstances()
{
GetInventoryItems(InventoryType.LSL).ForEach(i => StopScriptInstance(i));
}
/// <summary> /// <summary>
/// Start a script which is in this prim's inventory. /// Start a script which is in this prim's inventory.
/// </summary> /// </summary>
@ -443,7 +451,7 @@ namespace OpenSim.Region.Framework.Scenes
} }
/// <summary> /// <summary>
/// Stop a script which is in this prim's inventory. /// Stop and remove a script which is in this prim's inventory.
/// </summary> /// </summary>
/// <param name="itemId"></param> /// <param name="itemId"></param>
/// <param name="sceneObjectBeingDeleted"> /// <param name="sceneObjectBeingDeleted">
@ -470,7 +478,7 @@ namespace OpenSim.Region.Framework.Scenes
} }
else else
{ {
m_log.ErrorFormat( m_log.WarnFormat(
"[PRIM INVENTORY]: " + "[PRIM INVENTORY]: " +
"Couldn't stop script with ID {0} since it couldn't be found for prim {1}, {2} at {3} in {4}", "Couldn't stop script with ID {0} since it couldn't be found for prim {1}, {2} at {3} in {4}",
itemId, m_part.Name, m_part.UUID, itemId, m_part.Name, m_part.UUID,
@ -478,6 +486,51 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
/// <summary>
/// Stop a script which is in this prim's inventory.
/// </summary>
/// <param name="itemId"></param>
/// <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 StopScriptInstance(UUID itemId)
{
TaskInventoryItem scriptItem;
lock (m_items)
m_items.TryGetValue(itemId, out scriptItem);
if (scriptItem != null)
{
StopScriptInstance(scriptItem);
}
else
{
m_log.WarnFormat(
"[PRIM INVENTORY]: " +
"Couldn't stop script with ID {0} since it couldn't be found for prim {1}, {2} at {3} in {4}",
itemId, m_part.Name, m_part.UUID,
m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName);
}
}
/// <summary>
/// Stop a script which is in this prim's inventory.
/// </summary>
/// <param name="itemId"></param>
/// <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 StopScriptInstance(TaskInventoryItem item)
{
m_part.ParentGroup.Scene.EventManager.TriggerStopScript(m_part.LocalId, item.ItemID);
// At the moment, even stopped scripts are counted as active, which is probably wrong.
// m_part.ParentGroup.AddActiveScriptCount(-1);
}
/// <summary> /// <summary>
/// Check if the inventory holds an item with a given name. /// Check if the inventory holds an item with a given name.
/// </summary> /// </summary>

View File

@ -1895,7 +1895,7 @@ namespace OpenSim.Region.Framework.Scenes
) )
)); ));
m_log.DebugFormat("[SCENE PRESENCE]: {0} {1}", SitTargetisSet, SitTargetUnOccupied); // m_log.DebugFormat("[SCENE PRESENCE]: {0} {1}", SitTargetisSet, SitTargetUnOccupied);
if (PhysicsActor != null) if (PhysicsActor != null)
m_sitAvatarHeight = PhysicsActor.Size.Z; m_sitAvatarHeight = PhysicsActor.Size.Z;

View File

@ -26,6 +26,7 @@
*/ */
using System; using System;
using System.Collections.Generic;
using System.Reflection; using System.Reflection;
using Nini.Config; using Nini.Config;
using NUnit.Framework; using NUnit.Framework;
@ -69,6 +70,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests
m_sp.HandleAgentRequestSit(m_sp.ControllingClient, m_sp.UUID, part.UUID, Vector3.Zero); m_sp.HandleAgentRequestSit(m_sp.ControllingClient, m_sp.UUID, part.UUID, Vector3.Zero);
Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero)); Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero));
Assert.That(part.GetSittingAvatarsCount(), Is.EqualTo(0));
Assert.That(part.GetSittingAvatars(), Is.Null);
Assert.That(m_sp.ParentID, Is.EqualTo(0)); Assert.That(m_sp.ParentID, Is.EqualTo(0));
} }
@ -86,7 +89,13 @@ namespace OpenSim.Region.Framework.Scenes.Tests
m_sp.HandleAgentRequestSit(m_sp.ControllingClient, m_sp.UUID, part.UUID, Vector3.Zero); m_sp.HandleAgentRequestSit(m_sp.ControllingClient, m_sp.UUID, part.UUID, Vector3.Zero);
Assert.That(m_sp.PhysicsActor, Is.Null);
Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero)); Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero));
Assert.That(part.GetSittingAvatarsCount(), Is.EqualTo(1));
HashSet<UUID> sittingAvatars = part.GetSittingAvatars();
Assert.That(sittingAvatars.Count, Is.EqualTo(1));
Assert.That(sittingAvatars.Contains(m_sp.UUID));
Assert.That(m_sp.ParentID, Is.EqualTo(part.LocalId)); Assert.That(m_sp.ParentID, Is.EqualTo(part.LocalId));
} }
@ -104,10 +113,6 @@ namespace OpenSim.Region.Framework.Scenes.Tests
m_sp.HandleAgentRequestSit(m_sp.ControllingClient, m_sp.UUID, part.UUID, Vector3.Zero); m_sp.HandleAgentRequestSit(m_sp.ControllingClient, m_sp.UUID, part.UUID, Vector3.Zero);
Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero));
Assert.That(m_sp.ParentID, Is.EqualTo(part.LocalId));
Assert.That(m_sp.PhysicsActor, Is.Null);
// FIXME: This is different for live avatars - z position is adjusted. This is half the height of the // FIXME: This is different for live avatars - z position is adjusted. This is half the height of the
// default avatar. // default avatar.
// Curiously, Vector3.ToString() will not display the last two places of the float. For example, // Curiously, Vector3.ToString() will not display the last two places of the float. For example,
@ -119,6 +124,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests
m_sp.StandUp(); m_sp.StandUp();
Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero)); Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero));
Assert.That(part.GetSittingAvatarsCount(), Is.EqualTo(0));
Assert.That(part.GetSittingAvatars(), Is.Null);
Assert.That(m_sp.ParentID, Is.EqualTo(0)); Assert.That(m_sp.ParentID, Is.EqualTo(0));
Assert.That(m_sp.PhysicsActor, Is.Not.Null); Assert.That(m_sp.PhysicsActor, Is.Not.Null);
} }
@ -145,11 +152,20 @@ namespace OpenSim.Region.Framework.Scenes.Tests
Is.EqualTo(part.AbsolutePosition + part.SitTargetPosition + ScenePresence.SIT_TARGET_ADJUSTMENT)); Is.EqualTo(part.AbsolutePosition + part.SitTargetPosition + ScenePresence.SIT_TARGET_ADJUSTMENT));
Assert.That(m_sp.PhysicsActor, Is.Null); Assert.That(m_sp.PhysicsActor, Is.Null);
Assert.That(part.GetSittingAvatarsCount(), Is.EqualTo(1));
HashSet<UUID> sittingAvatars = part.GetSittingAvatars();
Assert.That(sittingAvatars.Count, Is.EqualTo(1));
Assert.That(sittingAvatars.Contains(m_sp.UUID));
m_sp.StandUp(); m_sp.StandUp();
Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero)); Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero));
Assert.That(m_sp.ParentID, Is.EqualTo(0)); Assert.That(m_sp.ParentID, Is.EqualTo(0));
Assert.That(m_sp.PhysicsActor, Is.Not.Null); Assert.That(m_sp.PhysicsActor, Is.Not.Null);
Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero));
Assert.That(part.GetSittingAvatarsCount(), Is.EqualTo(0));
Assert.That(part.GetSittingAvatars(), Is.Null);
} }
[Test] [Test]

View File

@ -179,7 +179,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
public void TestOsForceAttachToOtherAvatarFromInventory() public void TestOsForceAttachToOtherAvatarFromInventory()
{ {
TestHelpers.InMethod(); TestHelpers.InMethod();
TestHelpers.EnableLogging(); // TestHelpers.EnableLogging();
string taskInvObjItemName = "sphere"; string taskInvObjItemName = "sphere";
UUID taskInvObjItemId = UUID.Parse("00000000-0000-0000-0000-100000000000"); UUID taskInvObjItemId = UUID.Parse("00000000-0000-0000-0000-100000000000");

View File

@ -1574,7 +1574,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine
{ {
IScriptInstance instance = GetInstance(itemID); IScriptInstance instance = GetInstance(itemID);
if (instance != null) if (instance != null)
instance.Stop(0); {
// 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);
}
} }
public DetectParams GetDetectParams(UUID itemID, int idx) public DetectParams GetDetectParams(UUID itemID, int idx)

View File

@ -3081,6 +3081,7 @@
<ReferencePath>../../../bin/</ReferencePath> <ReferencePath>../../../bin/</ReferencePath>
<Reference name="System"/> <Reference name="System"/>
<Reference name="System.Core"/>
<Reference name="System.Xml"/> <Reference name="System.Xml"/>
<Reference name="System.Drawing"/> <Reference name="System.Drawing"/>
<Reference name="System.Runtime.Remoting"/> <Reference name="System.Runtime.Remoting"/>