mirror of
https://github.com/opensim/opensim.git
synced 2026-08-12 04:05:42 +08:00
If an agent is still registered as 'in transit' by the source region, don't allow an immediate teleport back.
This is to help relieve a race condition when an agent teleports then immediately attempts to teleport back before the source region has properly cleaned up/demoted the old ScenePresence. This is rare in viewers but much more possible via scripting or region module. However, more needs to be done since virtually all clean up happens after the transit flag is cleared . Possibly need to add a 'cleaning up' state to in transit. This change required making the EntityTransferModule and HGEntityTransferModule per-region rather than shared, in order to allow separate transit lists. Changes were also required in LocalSimulationConnector. Tested in standalone, grid and with local and remote region crossings with attachments.
This commit is contained in:
@@ -74,6 +74,13 @@ namespace OpenSim.Region.Framework.Interfaces
|
||||
/// <param name='client'></param>
|
||||
void TeleportHome(UUID id, IClientAPI client);
|
||||
|
||||
/// <summary>
|
||||
/// Show whether the given agent is being teleported.
|
||||
/// </summary>
|
||||
/// <returns>true if the agent is in the process of being teleported, false otherwise.</returns>
|
||||
/// <param name='id'>The agent ID</para></param>
|
||||
bool IsInTransit(UUID id);
|
||||
|
||||
bool Cross(ScenePresence agent, bool isFlying);
|
||||
|
||||
void AgentArrivedAtDestination(UUID agent);
|
||||
|
||||
@@ -166,7 +166,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
protected IConfigSource m_config;
|
||||
protected IRegionSerialiserModule m_serialiser;
|
||||
protected IDialogModule m_dialogModule;
|
||||
protected IEntityTransferModule m_teleportModule;
|
||||
protected ICapabilitiesModule m_capsModule;
|
||||
protected IGroupsModule m_groupsModule;
|
||||
|
||||
@@ -498,6 +497,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
}
|
||||
|
||||
public IAttachmentsModule AttachmentsModule { get; set; }
|
||||
public IEntityTransferModule EntityTransferModule { get; private set; }
|
||||
|
||||
public IAvatarFactoryModule AvatarFactory
|
||||
{
|
||||
@@ -924,8 +924,8 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
List<ulong> old = new List<ulong>();
|
||||
old.Add(otherRegion.RegionHandle);
|
||||
agent.DropOldNeighbours(old);
|
||||
if (m_teleportModule != null && agent.PresenceType != PresenceType.Npc)
|
||||
m_teleportModule.EnableChildAgent(agent, otherRegion);
|
||||
if (EntityTransferModule != null && agent.PresenceType != PresenceType.Npc)
|
||||
EntityTransferModule.EnableChildAgent(agent, otherRegion);
|
||||
});
|
||||
}
|
||||
catch (NullReferenceException)
|
||||
@@ -1062,8 +1062,8 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
{
|
||||
ForEachRootScenePresence(delegate(ScenePresence agent)
|
||||
{
|
||||
if (m_teleportModule != null && agent.PresenceType != PresenceType.Npc)
|
||||
m_teleportModule.EnableChildAgent(agent, r);
|
||||
if (EntityTransferModule != null && agent.PresenceType != PresenceType.Npc)
|
||||
EntityTransferModule.EnableChildAgent(agent, r);
|
||||
});
|
||||
}
|
||||
catch (NullReferenceException)
|
||||
@@ -1238,7 +1238,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
m_serialiser = RequestModuleInterface<IRegionSerialiserModule>();
|
||||
m_dialogModule = RequestModuleInterface<IDialogModule>();
|
||||
m_capsModule = RequestModuleInterface<ICapabilitiesModule>();
|
||||
m_teleportModule = RequestModuleInterface<IEntityTransferModule>();
|
||||
EntityTransferModule = RequestModuleInterface<IEntityTransferModule>();
|
||||
m_groupsModule = RequestModuleInterface<IGroupsModule>();
|
||||
}
|
||||
|
||||
@@ -2275,8 +2275,8 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_teleportModule != null)
|
||||
m_teleportModule.Cross(grp, attemptedPosition, silent);
|
||||
if (EntityTransferModule != null)
|
||||
EntityTransferModule.Cross(grp, attemptedPosition, silent);
|
||||
}
|
||||
|
||||
public Border GetCrossedBorder(Vector3 position, Cardinals gridline)
|
||||
@@ -3078,8 +3078,10 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
/// <param name="client">The IClientAPI for the client</param>
|
||||
public virtual void TeleportClientHome(UUID agentId, IClientAPI client)
|
||||
{
|
||||
if (m_teleportModule != null)
|
||||
m_teleportModule.TeleportHome(agentId, client);
|
||||
if (EntityTransferModule != null)
|
||||
{
|
||||
EntityTransferModule.TeleportHome(agentId, client);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active");
|
||||
@@ -3638,7 +3640,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
|
||||
private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason)
|
||||
{
|
||||
|
||||
bool banned = land.IsBannedFromLand(agent.AgentID);
|
||||
bool restricted = land.IsRestrictedFromLand(agent.AgentID);
|
||||
|
||||
@@ -4131,8 +4132,10 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
position.Y -= shifty;
|
||||
}
|
||||
|
||||
if (m_teleportModule != null)
|
||||
m_teleportModule.Teleport(sp, regionHandle, position, lookAt, teleportFlags);
|
||||
if (EntityTransferModule != null)
|
||||
{
|
||||
EntityTransferModule.Teleport(sp, regionHandle, position, lookAt, teleportFlags);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.DebugFormat("[SCENE]: Unable to perform teleports: no AgentTransferModule is active");
|
||||
@@ -4143,8 +4146,10 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
|
||||
public bool CrossAgentToNewRegion(ScenePresence agent, bool isFlying)
|
||||
{
|
||||
if (m_teleportModule != null)
|
||||
return m_teleportModule.Cross(agent, isFlying);
|
||||
if (EntityTransferModule != null)
|
||||
{
|
||||
return EntityTransferModule.Cross(agent, isFlying);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.DebugFormat("[SCENE]: Unable to cross agent to neighbouring region, because there is no AgentTransferModule");
|
||||
@@ -5188,14 +5193,34 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
throw new Exception(error);
|
||||
}
|
||||
|
||||
// This method is called across the simulation connector to
|
||||
// determine if a given agent is allowed in this region
|
||||
// AS A ROOT AGENT. Returning false here will prevent them
|
||||
// from logging into the region, teleporting into the region
|
||||
// or corssing the broder walking, but will NOT prevent
|
||||
// child agent creation, thereby emulating the SL behavior.
|
||||
/// <summary>
|
||||
/// This method is called across the simulation connector to
|
||||
/// determine if a given agent is allowed in this region
|
||||
/// AS A ROOT AGENT
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Returning false here will prevent them
|
||||
/// from logging into the region, teleporting into the region
|
||||
/// or corssing the broder walking, but will NOT prevent
|
||||
/// child agent creation, thereby emulating the SL behavior.
|
||||
/// </remarks>
|
||||
/// <param name='agentID'></param>
|
||||
/// <param name='position'></param>
|
||||
/// <param name='reason'></param>
|
||||
/// <returns></returns>
|
||||
public bool QueryAccess(UUID agentID, Vector3 position, out string reason)
|
||||
{
|
||||
if (EntityTransferModule.IsInTransit(agentID))
|
||||
{
|
||||
reason = "Agent is already in transit on this region";
|
||||
|
||||
m_log.DebugFormat(
|
||||
"[SCENE]: Denying agent {0} entry into {1} since region already has them registered as in transit",
|
||||
agentID, RegionInfo.RegionName);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// FIXME: Root agent count is currently known to be inaccurate. This forces a recount before we check.
|
||||
// However, the long term fix is to make sure root agent count is always accurate.
|
||||
m_sceneGraph.RecalculateStats();
|
||||
|
||||
@@ -110,12 +110,13 @@ namespace OpenSim.Region.Framework.Scenes.Tests
|
||||
|
||||
UUID userId = TestHelpers.ParseTail(0x1);
|
||||
|
||||
EntityTransferModule etm = new EntityTransferModule();
|
||||
EntityTransferModule etmA = new EntityTransferModule();
|
||||
EntityTransferModule etmB = new EntityTransferModule();
|
||||
LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
|
||||
|
||||
IConfigSource config = new IniConfigSource();
|
||||
IConfig modulesConfig = config.AddConfig("Modules");
|
||||
modulesConfig.Set("EntityTransferModule", etm.Name);
|
||||
modulesConfig.Set("EntityTransferModule", etmA.Name);
|
||||
modulesConfig.Set("SimulationServices", lscm.Name);
|
||||
IConfig entityTransferConfig = config.AddConfig("EntityTransfer");
|
||||
|
||||
@@ -127,7 +128,9 @@ namespace OpenSim.Region.Framework.Scenes.Tests
|
||||
TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
|
||||
TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1002, 1000);
|
||||
|
||||
SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, etm, lscm);
|
||||
SceneHelpers.SetupSceneModules(sceneA, config, etmA);
|
||||
SceneHelpers.SetupSceneModules(sceneB, config, etmB);
|
||||
SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
|
||||
|
||||
Vector3 teleportPosition = new Vector3(10, 11, 12);
|
||||
Vector3 teleportLookAt = new Vector3(20, 21, 22);
|
||||
@@ -174,12 +177,14 @@ namespace OpenSim.Region.Framework.Scenes.Tests
|
||||
UUID userId = TestHelpers.ParseTail(0x1);
|
||||
Vector3 preTeleportPosition = new Vector3(30, 31, 32);
|
||||
|
||||
EntityTransferModule etm = new EntityTransferModule();
|
||||
EntityTransferModule etmA = new EntityTransferModule();
|
||||
EntityTransferModule etmB = new EntityTransferModule();
|
||||
|
||||
LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
|
||||
|
||||
IConfigSource config = new IniConfigSource();
|
||||
config.AddConfig("Modules");
|
||||
config.Configs["Modules"].Set("EntityTransferModule", etm.Name);
|
||||
config.Configs["Modules"].Set("EntityTransferModule", etmA.Name);
|
||||
config.Configs["Modules"].Set("SimulationServices", lscm.Name);
|
||||
|
||||
config.AddConfig("EntityTransfer");
|
||||
@@ -195,13 +200,15 @@ namespace OpenSim.Region.Framework.Scenes.Tests
|
||||
TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
|
||||
TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1002, 1000);
|
||||
|
||||
SceneHelpers.SetupSceneModules(sceneA, config, etmA );
|
||||
|
||||
// We need to set up the permisions module on scene B so that our later use of agent limit to deny
|
||||
// QueryAccess won't succeed anyway because administrators are always allowed in and the default
|
||||
// IsAdministrator if no permissions module is present is true.
|
||||
SceneHelpers.SetupSceneModules(sceneB, config, new object[] { new PermissionsModule() });
|
||||
SceneHelpers.SetupSceneModules(sceneB, config, new object[] { new PermissionsModule(), etmB });
|
||||
|
||||
// Shared scene modules
|
||||
SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, etm, lscm);
|
||||
SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
|
||||
|
||||
Vector3 teleportPosition = new Vector3(10, 11, 12);
|
||||
Vector3 teleportLookAt = new Vector3(20, 21, 22);
|
||||
@@ -249,12 +256,13 @@ namespace OpenSim.Region.Framework.Scenes.Tests
|
||||
UUID userId = TestHelpers.ParseTail(0x1);
|
||||
Vector3 preTeleportPosition = new Vector3(30, 31, 32);
|
||||
|
||||
EntityTransferModule etm = new EntityTransferModule();
|
||||
EntityTransferModule etmA = new EntityTransferModule();
|
||||
EntityTransferModule etmB = new EntityTransferModule();
|
||||
LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
|
||||
|
||||
IConfigSource config = new IniConfigSource();
|
||||
config.AddConfig("Modules");
|
||||
config.Configs["Modules"].Set("EntityTransferModule", etm.Name);
|
||||
config.Configs["Modules"].Set("EntityTransferModule", etmA.Name);
|
||||
config.Configs["Modules"].Set("SimulationServices", lscm.Name);
|
||||
|
||||
config.AddConfig("EntityTransfer");
|
||||
@@ -267,8 +275,11 @@ namespace OpenSim.Region.Framework.Scenes.Tests
|
||||
TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
|
||||
TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1002, 1000);
|
||||
|
||||
SceneHelpers.SetupSceneModules(sceneA, config, etmA);
|
||||
SceneHelpers.SetupSceneModules(sceneB, config, etmB);
|
||||
|
||||
// Shared scene modules
|
||||
SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, etm, lscm);
|
||||
SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
|
||||
|
||||
Vector3 teleportPosition = new Vector3(10, 11, 12);
|
||||
Vector3 teleportLookAt = new Vector3(20, 21, 22);
|
||||
@@ -312,12 +323,13 @@ namespace OpenSim.Region.Framework.Scenes.Tests
|
||||
|
||||
UUID userId = TestHelpers.ParseTail(0x1);
|
||||
|
||||
EntityTransferModule etm = new EntityTransferModule();
|
||||
EntityTransferModule etmA = new EntityTransferModule();
|
||||
EntityTransferModule etmB = new EntityTransferModule();
|
||||
LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
|
||||
|
||||
IConfigSource config = new IniConfigSource();
|
||||
IConfig modulesConfig = config.AddConfig("Modules");
|
||||
modulesConfig.Set("EntityTransferModule", etm.Name);
|
||||
modulesConfig.Set("EntityTransferModule", etmA.Name);
|
||||
modulesConfig.Set("SimulationServices", lscm.Name);
|
||||
IConfig entityTransferConfig = config.AddConfig("EntityTransfer");
|
||||
|
||||
@@ -329,9 +341,9 @@ namespace OpenSim.Region.Framework.Scenes.Tests
|
||||
TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
|
||||
TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1001, 1000);
|
||||
|
||||
SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, etm, lscm);
|
||||
SceneHelpers.SetupSceneModules(sceneA, new CapabilitiesModule());
|
||||
SceneHelpers.SetupSceneModules(sceneB, new CapabilitiesModule());
|
||||
SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
|
||||
SceneHelpers.SetupSceneModules(sceneA, config, new CapabilitiesModule(), etmA);
|
||||
SceneHelpers.SetupSceneModules(sceneB, config, new CapabilitiesModule(), etmB);
|
||||
|
||||
Vector3 teleportPosition = new Vector3(10, 11, 12);
|
||||
Vector3 teleportLookAt = new Vector3(20, 21, 22);
|
||||
|
||||
Reference in New Issue
Block a user