From e99a7d879ecf59737e9916a9eb229698ef866627 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Thu, 16 Jan 2014 00:05:04 +0000
Subject: Remove old IInterRegionComms and references. This hasn't been used
since 2009 and was superseded by ISimulationService
---
.../Framework/Interfaces/IInterregionComms.cs | 111 ---------------------
OpenSim/Region/Framework/Scenes/Scene.cs | 12 ---
2 files changed, 123 deletions(-)
delete mode 100644 OpenSim/Region/Framework/Interfaces/IInterregionComms.cs
(limited to 'OpenSim/Region/Framework')
diff --git a/OpenSim/Region/Framework/Interfaces/IInterregionComms.cs b/OpenSim/Region/Framework/Interfaces/IInterregionComms.cs
deleted file mode 100644
index 2d6287f..0000000
--- a/OpenSim/Region/Framework/Interfaces/IInterregionComms.cs
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Copyright (c) Contributors, http://opensimulator.org/
- * See CONTRIBUTORS.TXT for a full list of copyright holders.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the OpenSimulator Project nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-using OpenMetaverse;
-using OpenSim.Framework;
-using OpenSim.Region.Framework.Scenes;
-
-namespace OpenSim.Region.Framework.Interfaces
-{
- public delegate bool ChildAgentUpdateReceived(AgentData data);
-
- public interface IInterregionCommsOut
- {
- #region Agents
-
- bool SendCreateChildAgent(ulong regionHandle, AgentCircuitData aCircuit, uint teleportFlags, out string reason);
-
- ///
- /// Full child agent update.
- ///
- ///
- ///
- ///
- bool SendChildAgentUpdate(ulong regionHandle, AgentData data);
-
- ///
- /// Short child agent update, mostly for position.
- ///
- ///
- ///
- ///
- bool SendChildAgentUpdate(ulong regionHandle, AgentPosition data);
-
- bool SendRetrieveRootAgent(ulong regionHandle, UUID id, out IAgentData agent);
-
- ///
- /// Message from receiving region to departing region, telling it got contacted by the client.
- /// When sent over REST, it invokes the opaque uri.
- ///
- ///
- ///
- ///
- ///
- bool SendReleaseAgent(ulong regionHandle, UUID id, string uri);
-
- ///
- /// Close agent.
- ///
- ///
- ///
- ///
- bool SendCloseAgent(ulong regionHandle, UUID id);
-
- #endregion Agents
-
- #region Objects
-
- ///
- /// Create an object in the destination region. This message is used primarily for prim crossing.
- ///
- ///
- ///
- ///
- ///
- bool SendCreateObject(ulong regionHandle, SceneObjectGroup sog, bool isLocalCall);
-
- ///
- /// Create an object from the user's inventory in the destination region.
- /// This message is used primarily by clients.
- ///
- ///
- ///
- ///
- ///
- bool SendCreateObject(ulong regionHandle, UUID userID, UUID itemID);
-
- #endregion Objects
-
- }
-
- // This may not be needed, but having it here for now.
- public interface IInterregionCommsIn
- {
- event ChildAgentUpdateReceived OnChildAgentUpdate;
- }
-
-}
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 7772f94..567ce2a 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -4405,18 +4405,6 @@ namespace OpenSim.Region.Framework.Scenes
return sp;
}
- public virtual bool IncomingRetrieveRootAgent(UUID id, out IAgentData agent)
- {
- agent = null;
- ScenePresence sp = GetScenePresence(id);
- if ((sp != null) && (!sp.IsChildAgent))
- {
- sp.IsChildAgent = true;
- return sp.CopyAgent(out agent);
- }
-
- return false;
- }
///
/// Authenticated close (via network)
///
--
cgit v1.1
From 3ffd90496a366f2b64eb8daadf63a2b6ee05ad7a Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Thu, 16 Jan 2014 20:23:31 +0000
Subject: Prevent duplicate invocations or race dontision in
SP.CompleteMovement()
This can happen under poor network conditions if a viewer repeats the message send
If this happens, physics actors can get orphaned, which unecessarily raises physics frame times
---
OpenSim/Region/Framework/Scenes/ScenePresence.cs | 29 ++++++-
.../Scenes/Tests/ScenePresenceAgentTests.cs | 92 +++++++++-------------
2 files changed, 65 insertions(+), 56 deletions(-)
(limited to 'OpenSim/Region/Framework')
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 49f70c4..63cca56 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -108,6 +108,16 @@ namespace OpenSim.Region.Framework.Scenes
}
}
+ ///
+ /// This exists to prevent race conditions between two CompleteMovement threads if the simulator is slow and
+ /// the viewer fires these in quick succession.
+ ///
+ ///
+ /// TODO: The child -> agent transition should be folded into LifecycleState and the CompleteMovement
+ /// regulation done there.
+ ///
+ private object m_completeMovementLock = new object();
+
// private static readonly byte[] DEFAULT_TEXTURE = AvatarAppearance.GetDefaultTexture().GetBytes();
private static readonly Array DIR_CONTROL_FLAGS = Enum.GetValues(typeof(Dir_ControlFlags));
private static readonly Vector3 HEAD_ADJUSTMENT = new Vector3(0f, 0f, 0.3f);
@@ -905,6 +915,7 @@ namespace OpenSim.Region.Framework.Scenes
///
/// Turns a child agent into a root agent.
///
+ ///
/// Child agents are logged into neighbouring sims largely to observe changes. Root agents exist when the
/// avatar is actual in the sim. They can perform all actions.
/// This change is made whenever an avatar enters a region, whether by crossing over from a neighbouring sim,
@@ -912,8 +923,8 @@ namespace OpenSim.Region.Framework.Scenes
///
/// This method is on the critical path for transferring an avatar from one region to another. Delay here
/// delays that crossing.
- ///
- private void MakeRootAgent(Vector3 pos, bool isFlying)
+ ///
+ private bool MakeRootAgent(Vector3 pos, bool isFlying)
{
// m_log.InfoFormat(
// "[SCENE]: Upgrading child to root agent for {0} in {1}",
@@ -921,6 +932,10 @@ namespace OpenSim.Region.Framework.Scenes
//m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count);
+ lock (m_completeMovementLock)
+ if (!IsChildAgent)
+ return false;
+
IsChildAgent = false;
// Must reset this here so that a teleport to a region next to an existing region does not keep the flag
@@ -1070,6 +1085,7 @@ namespace OpenSim.Region.Framework.Scenes
m_scene.EventManager.TriggerOnMakeRootAgent(this);
+ return true;
}
public int GetStateSource()
@@ -1443,7 +1459,14 @@ namespace OpenSim.Region.Framework.Scenes
}
bool flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0);
- MakeRootAgent(AbsolutePosition, flying);
+ if (!MakeRootAgent(AbsolutePosition, flying))
+ {
+ m_log.DebugFormat(
+ "[SCENE PRESENCE]: Aborting CompleteMovement call for {0} in {1} as they are already root",
+ Name, Scene.Name);
+
+ return;
+ }
// Tell the client that we're totally ready
ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look);
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs
index d1aeaee..1ff1329 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs
@@ -111,6 +111,45 @@ namespace OpenSim.Region.Framework.Scenes.Tests
Assert.That(scene.GetScenePresences().Count, Is.EqualTo(1));
}
+ ///
+ /// Test that duplicate complete movement calls are ignored.
+ ///
+ ///
+ /// If duplicate calls are not ignored then there is a risk of race conditions or other unexpected effects.
+ ///
+ [Test]
+ public void TestDupeCompleteMovementCalls()
+ {
+ TestHelpers.InMethod();
+// TestHelpers.EnableLogging();
+
+ UUID spUuid = TestHelpers.ParseTail(0x1);
+
+ TestScene scene = new SceneHelpers().SetupScene();
+
+ int makeRootAgentEvents = 0;
+ scene.EventManager.OnMakeRootAgent += spi => makeRootAgentEvents++;
+
+ ScenePresence sp = SceneHelpers.AddScenePresence(scene, spUuid);
+
+ Assert.That(makeRootAgentEvents, Is.EqualTo(1));
+
+ // Normally these would be invoked by a CompleteMovement message coming in to the UDP stack. But for
+ // convenience, here we will invoke it manually.
+ sp.CompleteMovement(sp.ControllingClient, true);
+
+ Assert.That(makeRootAgentEvents, Is.EqualTo(1));
+
+ // Check rest of exepcted parameters.
+ Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(spUuid), Is.Not.Null);
+ Assert.That(scene.AuthenticateHandler.GetAgentCircuits().Count, Is.EqualTo(1));
+
+ Assert.That(sp.IsChildAgent, Is.False);
+ Assert.That(sp.UUID, Is.EqualTo(spUuid));
+
+ Assert.That(scene.GetScenePresences().Count, Is.EqualTo(1));
+ }
+
[Test]
public void TestCreateDuplicateRootScenePresence()
{
@@ -249,58 +288,5 @@ namespace OpenSim.Region.Framework.Scenes.Tests
// Assert.That(childPresence, Is.Not.Null);
// Assert.That(childPresence.IsChildAgent, Is.True);
}
-
-// ///
-// /// Test adding a root agent to a scene. Doesn't yet actually complete crossing the agent into the scene.
-// ///
-// [Test]
-// public void T010_TestAddRootAgent()
-// {
-// TestHelpers.InMethod();
-//
-// string firstName = "testfirstname";
-//
-// AgentCircuitData agent = new AgentCircuitData();
-// agent.AgentID = agent1;
-// agent.firstname = firstName;
-// agent.lastname = "testlastname";
-// agent.SessionID = UUID.Random();
-// agent.SecureSessionID = UUID.Random();
-// agent.circuitcode = 123;
-// agent.BaseFolder = UUID.Zero;
-// agent.InventoryFolder = UUID.Zero;
-// agent.startpos = Vector3.Zero;
-// agent.CapsPath = GetRandomCapsObjectPath();
-// agent.ChildrenCapSeeds = new Dictionary();
-// agent.child = true;
-//
-// scene.PresenceService.LoginAgent(agent.AgentID.ToString(), agent.SessionID, agent.SecureSessionID);
-//
-// string reason;
-// scene.NewUserConnection(agent, (uint)TeleportFlags.ViaLogin, out reason);
-// testclient = new TestClient(agent, scene);
-// scene.AddNewAgent(testclient);
-//
-// ScenePresence presence = scene.GetScenePresence(agent1);
-//
-// Assert.That(presence, Is.Not.Null, "presence is null");
-// Assert.That(presence.Firstname, Is.EqualTo(firstName), "First name not same");
-// acd1 = agent;
-// }
-//
-// ///
-// /// Test removing an uncrossed root agent from a scene.
-// ///
-// [Test]
-// public void T011_TestRemoveRootAgent()
-// {
-// TestHelpers.InMethod();
-//
-// scene.RemoveClient(agent1);
-//
-// ScenePresence presence = scene.GetScenePresence(agent1);
-//
-// Assert.That(presence, Is.Null, "presence is not null");
-// }
}
}
\ No newline at end of file
--
cgit v1.1
From 3bc669ffc7638b56d5ab5aac038c33106ba9a95b Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Thu, 16 Jan 2014 23:31:50 +0000
Subject: Actually put IsChildAgent = true inside the lock, otherwise there is
still a small window for race conditions on duplicate CompleteMovement calls
---
OpenSim/Region/Framework/Scenes/ScenePresence.cs | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
(limited to 'OpenSim/Region/Framework')
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 63cca56..3290da1 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -933,10 +933,12 @@ namespace OpenSim.Region.Framework.Scenes
//m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count);
lock (m_completeMovementLock)
+ {
if (!IsChildAgent)
return false;
- IsChildAgent = false;
+ IsChildAgent = false;
+ }
// Must reset this here so that a teleport to a region next to an existing region does not keep the flag
// set and prevent the close of the connection on a subsequent re-teleport.
--
cgit v1.1
From 4fa843ff19441c9daa4e7dae0a4d705f912fca54 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Thu, 16 Jan 2014 23:44:17 +0000
Subject: Reorder checks in SP.CompleteMovement() to fix test failures
---
OpenSim/Region/Framework/Scenes/ScenePresence.cs | 69 ++++++++++++------------
1 file changed, 33 insertions(+), 36 deletions(-)
(limited to 'OpenSim/Region/Framework')
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 18d84a2..85a20e9 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -1003,48 +1003,45 @@ namespace OpenSim.Region.Framework.Scenes
///
private bool MakeRootAgent(Vector3 pos, bool isFlying)
{
-// m_log.InfoFormat(
-// "[SCENE]: Upgrading child to root agent for {0} in {1}",
-// Name, m_scene.RegionInfo.RegionName);
-
- if (ParentUUID != UUID.Zero)
+ lock (m_completeMovementLock)
{
- m_log.DebugFormat("[SCENE PRESENCE]: Sitting avatar back on prim {0}", ParentUUID);
- SceneObjectPart part = m_scene.GetSceneObjectPart(ParentUUID);
- if (part == null)
+ if (!IsChildAgent)
+ return false;
+
+ //m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count);
+
+ // m_log.InfoFormat(
+ // "[SCENE]: Upgrading child to root agent for {0} in {1}",
+ // Name, m_scene.RegionInfo.RegionName);
+
+ if (ParentUUID != UUID.Zero)
{
- m_log.ErrorFormat("[SCENE PRESENCE]: Can't find prim {0} to sit on", ParentUUID);
+ m_log.DebugFormat("[SCENE PRESENCE]: Sitting avatar back on prim {0}", ParentUUID);
+ SceneObjectPart part = m_scene.GetSceneObjectPart(ParentUUID);
+ if (part == null)
+ {
+ m_log.ErrorFormat("[SCENE PRESENCE]: Can't find prim {0} to sit on", ParentUUID);
+ }
+ else
+ {
+ part.ParentGroup.AddAvatar(UUID);
+ if (part.SitTargetPosition != Vector3.Zero)
+ part.SitTargetAvatar = UUID;
+ // ParentPosition = part.GetWorldPosition();
+ ParentID = part.LocalId;
+ ParentPart = part;
+ m_pos = PrevSitOffset;
+ // pos = ParentPosition;
+ pos = part.GetWorldPosition();
+ }
+ ParentUUID = UUID.Zero;
+
+ // Animator.TrySetMovementAnimation("SIT");
}
else
{
- part.ParentGroup.AddAvatar(UUID);
- if (part.SitTargetPosition != Vector3.Zero)
- part.SitTargetAvatar = UUID;
-// ParentPosition = part.GetWorldPosition();
- ParentID = part.LocalId;
- ParentPart = part;
- m_pos = PrevSitOffset;
-// pos = ParentPosition;
- pos = part.GetWorldPosition();
+ IsLoggingIn = false;
}
- ParentUUID = UUID.Zero;
-
- IsChildAgent = false;
-
-// Animator.TrySetMovementAnimation("SIT");
- }
- else
- {
- IsChildAgent = false;
- IsLoggingIn = false;
- }
-
- //m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count);
-
- lock (m_completeMovementLock)
- {
- if (!IsChildAgent)
- return false;
IsChildAgent = false;
}
--
cgit v1.1
From b52b50ee56f3461d7f2dc47a905a0b10d07d3346 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 17 Jan 2014 23:36:23 +0000
Subject: minor: reinsert some method doc back into IEntityTransferModule
---
.../Framework/Interfaces/IEntityTransferModule.cs | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
(limited to 'OpenSim/Region/Framework')
diff --git a/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs b/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs
index 1949a90..214b07a 100644
--- a/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs
@@ -47,13 +47,33 @@ namespace OpenSim.Region.Framework.Interfaces
/// The handle of the destination region. If it's the same as the region currently
/// occupied by the agent then the teleport will be within that region.
///
+ ///
+ ///
///
///
///
void Teleport(ScenePresence agent, ulong regionHandle, Vector3 position, Vector3 lookAt, uint teleportFlags);
+ ///
+ /// Teleports the agent for the given client to their home destination.
+ ///
+ ///
+ ///
bool TeleportHome(UUID id, IClientAPI client);
+ ///
+ /// Teleport an agent directly to a given region without checking whether the region should be substituted.
+ ///
+ ///
+ /// Please use Teleport() instead unless you know exactly what you're doing.
+ /// Do not use for same region teleports.
+ ///
+ ///
+ ///
+ /// /param>
+ ///
+ ///
+ ///
void DoTeleport(ScenePresence sp, GridRegion reg, GridRegion finalDestination,
Vector3 position, Vector3 lookAt, uint teleportFlags);
--
cgit v1.1