diff options
author | Justin Clark-Casey (justincc) | 2012-05-24 00:31:14 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2012-05-24 00:31:14 +0100 |
commit | 459c7635afdbc4002cacbf5780185645a4296f6a (patch) | |
tree | 9cf90fb39bc20e9283d6702d102475db08ca53d3 /OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs | |
parent | Environment Module - allows Environment settings for Viewer3 warning: include... (diff) | |
download | opensim-SC_OLD-459c7635afdbc4002cacbf5780185645a4296f6a.zip opensim-SC_OLD-459c7635afdbc4002cacbf5780185645a4296f6a.tar.gz opensim-SC_OLD-459c7635afdbc4002cacbf5780185645a4296f6a.tar.bz2 opensim-SC_OLD-459c7635afdbc4002cacbf5780185645a4296f6a.tar.xz |
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.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs | 55 |
1 files changed, 28 insertions, 27 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs index b578bcb..4124667 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs | |||
@@ -45,11 +45,11 @@ using Nini.Config; | |||
45 | 45 | ||
46 | namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | 46 | namespace OpenSim.Region.CoreModules.Framework.EntityTransfer |
47 | { | 47 | { |
48 | public class HGEntityTransferModule : EntityTransferModule, ISharedRegionModule, IEntityTransferModule, IUserAgentVerificationModule | 48 | public class HGEntityTransferModule |
49 | : EntityTransferModule, INonSharedRegionModule, IEntityTransferModule, IUserAgentVerificationModule | ||
49 | { | 50 | { |
50 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 51 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
51 | 52 | ||
52 | private bool m_Initialized = false; | ||
53 | private int m_levelHGTeleport = 0; | 53 | private int m_levelHGTeleport = 0; |
54 | 54 | ||
55 | private GatekeeperServiceConnector m_GatekeeperConnector; | 55 | private GatekeeperServiceConnector m_GatekeeperConnector; |
@@ -64,6 +64,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
64 | public override void Initialise(IConfigSource source) | 64 | public override void Initialise(IConfigSource source) |
65 | { | 65 | { |
66 | IConfig moduleConfig = source.Configs["Modules"]; | 66 | IConfig moduleConfig = source.Configs["Modules"]; |
67 | |||
67 | if (moduleConfig != null) | 68 | if (moduleConfig != null) |
68 | { | 69 | { |
69 | string name = moduleConfig.GetString("EntityTransferModule", ""); | 70 | string name = moduleConfig.GetString("EntityTransferModule", ""); |
@@ -82,10 +83,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
82 | public override void AddRegion(Scene scene) | 83 | public override void AddRegion(Scene scene) |
83 | { | 84 | { |
84 | base.AddRegion(scene); | 85 | base.AddRegion(scene); |
86 | |||
85 | if (m_Enabled) | 87 | if (m_Enabled) |
86 | { | ||
87 | scene.RegisterModuleInterface<IUserAgentVerificationModule>(this); | 88 | scene.RegisterModuleInterface<IUserAgentVerificationModule>(this); |
88 | } | ||
89 | } | 89 | } |
90 | 90 | ||
91 | protected override void OnNewClient(IClientAPI client) | 91 | protected override void OnNewClient(IClientAPI client) |
@@ -98,33 +98,28 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
98 | public override void RegionLoaded(Scene scene) | 98 | public override void RegionLoaded(Scene scene) |
99 | { | 99 | { |
100 | base.RegionLoaded(scene); | 100 | base.RegionLoaded(scene); |
101 | if (m_Enabled) | ||
102 | if (!m_Initialized) | ||
103 | { | ||
104 | m_GatekeeperConnector = new GatekeeperServiceConnector(scene.AssetService); | ||
105 | m_Initialized = true; | ||
106 | |||
107 | } | ||
108 | 101 | ||
102 | if (m_Enabled) | ||
103 | m_GatekeeperConnector = new GatekeeperServiceConnector(scene.AssetService); | ||
109 | } | 104 | } |
105 | |||
110 | public override void RemoveRegion(Scene scene) | 106 | public override void RemoveRegion(Scene scene) |
111 | { | 107 | { |
112 | base.AddRegion(scene); | 108 | base.AddRegion(scene); |
109 | |||
113 | if (m_Enabled) | 110 | if (m_Enabled) |
114 | { | ||
115 | scene.UnregisterModuleInterface<IUserAgentVerificationModule>(this); | 111 | scene.UnregisterModuleInterface<IUserAgentVerificationModule>(this); |
116 | } | ||
117 | } | 112 | } |
118 | 113 | ||
119 | |||
120 | #endregion | 114 | #endregion |
121 | 115 | ||
122 | #region HG overrides of IEntiryTransferModule | 116 | #region HG overrides of IEntiryTransferModule |
123 | 117 | ||
124 | protected override GridRegion GetFinalDestination(GridRegion region) | 118 | protected override GridRegion GetFinalDestination(GridRegion region) |
125 | { | 119 | { |
126 | int flags = m_aScene.GridService.GetRegionFlags(m_aScene.RegionInfo.ScopeID, region.RegionID); | 120 | int flags = m_scene.GridService.GetRegionFlags(m_scene.RegionInfo.ScopeID, region.RegionID); |
127 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: region {0} flags: {1}", region.RegionID, flags); | 121 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: region {0} flags: {1}", region.RegionID, flags); |
122 | |||
128 | if ((flags & (int)OpenSim.Data.RegionFlags.Hyperlink) != 0) | 123 | if ((flags & (int)OpenSim.Data.RegionFlags.Hyperlink) != 0) |
129 | { | 124 | { |
130 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Destination region {0} is hyperlink", region.RegionID); | 125 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Destination region {0} is hyperlink", region.RegionID); |
@@ -135,6 +130,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
135 | m_log.WarnFormat("[HG ENTITY TRANSFER MODULE]: GetHyperlinkRegion to Gatekeeper {0} failed", region.ServerURI); | 130 | m_log.WarnFormat("[HG ENTITY TRANSFER MODULE]: GetHyperlinkRegion to Gatekeeper {0} failed", region.ServerURI); |
136 | return real_destination; | 131 | return real_destination; |
137 | } | 132 | } |
133 | |||
138 | return region; | 134 | return region; |
139 | } | 135 | } |
140 | 136 | ||
@@ -143,7 +139,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
143 | if (base.NeedsClosing(drawdist, oldRegionX, newRegionX, oldRegionY, newRegionY, reg)) | 139 | if (base.NeedsClosing(drawdist, oldRegionX, newRegionX, oldRegionY, newRegionY, reg)) |
144 | return true; | 140 | return true; |
145 | 141 | ||
146 | int flags = m_aScene.GridService.GetRegionFlags(m_aScene.RegionInfo.ScopeID, reg.RegionID); | 142 | int flags = m_scene.GridService.GetRegionFlags(m_scene.RegionInfo.ScopeID, reg.RegionID); |
147 | if (flags == -1 /* no region in DB */ || (flags & (int)OpenSim.Data.RegionFlags.Hyperlink) != 0) | 143 | if (flags == -1 /* no region in DB */ || (flags & (int)OpenSim.Data.RegionFlags.Hyperlink) != 0) |
148 | return true; | 144 | return true; |
149 | 145 | ||
@@ -156,7 +152,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
156 | if (logout) | 152 | if (logout) |
157 | { | 153 | { |
158 | // Log them out of this grid | 154 | // Log them out of this grid |
159 | m_aScene.PresenceService.LogoutAgent(sp.ControllingClient.SessionId); | 155 | m_scene.PresenceService.LogoutAgent(sp.ControllingClient.SessionId); |
160 | } | 156 | } |
161 | } | 157 | } |
162 | 158 | ||
@@ -165,7 +161,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
165 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: CreateAgent {0} {1}", reg.ServerURI, finalDestination.ServerURI); | 161 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: CreateAgent {0} {1}", reg.ServerURI, finalDestination.ServerURI); |
166 | reason = string.Empty; | 162 | reason = string.Empty; |
167 | logout = false; | 163 | logout = false; |
168 | int flags = m_aScene.GridService.GetRegionFlags(m_aScene.RegionInfo.ScopeID, reg.RegionID); | 164 | int flags = m_scene.GridService.GetRegionFlags(m_scene.RegionInfo.ScopeID, reg.RegionID); |
169 | if (flags == -1 /* no region in DB */ || (flags & (int)OpenSim.Data.RegionFlags.Hyperlink) != 0) | 165 | if (flags == -1 /* no region in DB */ || (flags & (int)OpenSim.Data.RegionFlags.Hyperlink) != 0) |
170 | { | 166 | { |
171 | // this user is going to another grid | 167 | // this user is going to another grid |
@@ -205,7 +201,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
205 | "[ENTITY TRANSFER MODULE]: Request to teleport {0} {1} home", client.Name, client.AgentId); | 201 | "[ENTITY TRANSFER MODULE]: Request to teleport {0} {1} home", client.Name, client.AgentId); |
206 | 202 | ||
207 | // Let's find out if this is a foreign user or a local user | 203 | // Let's find out if this is a foreign user or a local user |
208 | IUserManagement uMan = m_aScene.RequestModuleInterface<IUserManagement>(); | 204 | IUserManagement uMan = m_scene.RequestModuleInterface<IUserManagement>(); |
209 | if (uMan != null && uMan.IsLocalGridUser(id)) | 205 | if (uMan != null && uMan.IsLocalGridUser(id)) |
210 | { | 206 | { |
211 | // local grid user | 207 | // local grid user |
@@ -262,19 +258,21 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
262 | { | 258 | { |
263 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Teleporting agent via landmark to {0} region {1} position {2}", | 259 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Teleporting agent via landmark to {0} region {1} position {2}", |
264 | (lm.Gatekeeper == string.Empty) ? "local" : lm.Gatekeeper, lm.RegionID, lm.Position); | 260 | (lm.Gatekeeper == string.Empty) ? "local" : lm.Gatekeeper, lm.RegionID, lm.Position); |
261 | |||
265 | if (lm.Gatekeeper == string.Empty) | 262 | if (lm.Gatekeeper == string.Empty) |
266 | { | 263 | { |
267 | base.RequestTeleportLandmark(remoteClient, lm); | 264 | base.RequestTeleportLandmark(remoteClient, lm); |
268 | return; | 265 | return; |
269 | } | 266 | } |
270 | 267 | ||
271 | GridRegion info = m_aScene.GridService.GetRegionByUUID(UUID.Zero, lm.RegionID); | 268 | GridRegion info = m_scene.GridService.GetRegionByUUID(UUID.Zero, lm.RegionID); |
272 | 269 | ||
273 | // Local region? | 270 | // Local region? |
274 | if (info != null) | 271 | if (info != null) |
275 | { | 272 | { |
276 | ((Scene)(remoteClient.Scene)).RequestTeleportLocation(remoteClient, info.RegionHandle, lm.Position, | 273 | ((Scene)(remoteClient.Scene)).RequestTeleportLocation(remoteClient, info.RegionHandle, lm.Position, |
277 | Vector3.Zero, (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaLandmark)); | 274 | Vector3.Zero, (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaLandmark)); |
275 | |||
278 | return; | 276 | return; |
279 | } | 277 | } |
280 | else | 278 | else |
@@ -285,6 +283,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
285 | GridRegion gatekeeper = new GridRegion(); | 283 | GridRegion gatekeeper = new GridRegion(); |
286 | gatekeeper.ServerURI = lm.Gatekeeper; | 284 | gatekeeper.ServerURI = lm.Gatekeeper; |
287 | GridRegion finalDestination = gConn.GetHyperlinkRegion(gatekeeper, new UUID(lm.RegionID)); | 285 | GridRegion finalDestination = gConn.GetHyperlinkRegion(gatekeeper, new UUID(lm.RegionID)); |
286 | |||
288 | if (finalDestination != null) | 287 | if (finalDestination != null) |
289 | { | 288 | { |
290 | ScenePresence sp = scene.GetScenePresence(remoteClient.AgentId); | 289 | ScenePresence sp = scene.GetScenePresence(remoteClient.AgentId); |
@@ -314,8 +313,12 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
314 | IUserAgentService security = new UserAgentServiceConnector(url); | 313 | IUserAgentService security = new UserAgentServiceConnector(url); |
315 | return security.VerifyClient(aCircuit.SessionID, token); | 314 | return security.VerifyClient(aCircuit.SessionID, token); |
316 | } | 315 | } |
317 | else | 316 | else |
318 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Agent {0} {1} does not have a HomeURI OH NO!", aCircuit.firstname, aCircuit.lastname); | 317 | { |
318 | m_log.DebugFormat( | ||
319 | "[HG ENTITY TRANSFER MODULE]: Agent {0} {1} does not have a HomeURI OH NO!", | ||
320 | aCircuit.firstname, aCircuit.lastname); | ||
321 | } | ||
319 | 322 | ||
320 | return false; | 323 | return false; |
321 | } | 324 | } |
@@ -332,8 +335,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
332 | } | 335 | } |
333 | 336 | ||
334 | // Let's find out if this is a foreign user or a local user | 337 | // Let's find out if this is a foreign user or a local user |
335 | IUserManagement uMan = m_aScene.RequestModuleInterface<IUserManagement>(); | 338 | IUserManagement uMan = m_scene.RequestModuleInterface<IUserManagement>(); |
336 | UserAccount account = m_aScene.UserAccountService.GetUserAccount(m_aScene.RegionInfo.ScopeID, obj.AgentId); | 339 | UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, obj.AgentId); |
337 | if (uMan != null && uMan.IsLocalGridUser(obj.AgentId)) | 340 | if (uMan != null && uMan.IsLocalGridUser(obj.AgentId)) |
338 | { | 341 | { |
339 | // local grid user | 342 | // local grid user |
@@ -356,7 +359,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
356 | 359 | ||
357 | #endregion | 360 | #endregion |
358 | 361 | ||
359 | |||
360 | private GridRegion MakeRegion(AgentCircuitData aCircuit) | 362 | private GridRegion MakeRegion(AgentCircuitData aCircuit) |
361 | { | 363 | { |
362 | GridRegion region = new GridRegion(); | 364 | GridRegion region = new GridRegion(); |
@@ -373,6 +375,5 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
373 | region.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), (int)0); | 375 | region.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), (int)0); |
374 | return region; | 376 | return region; |
375 | } | 377 | } |
376 | |||
377 | } | 378 | } |
378 | } | 379 | } \ No newline at end of file |