From 2231fcf5b45be9a2f5b6e1a2665ff7223e275b33 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 15 Aug 2013 13:46:46 +0100 Subject: Do not use the SP.DoNotCloseAfterTeleport flag for child agent connections. This approach has problems if a client quits without sending a proper logout but then reconnects before the connection is closed due to inactivity. In this case, the DoNotCloseAfterTeleport was wrongly set. The simplest approach is to close child agents on teleport as quickly as possible so that races are very unlikely to occur Hence, this code now closes child agents as the first action after a sucessful teleport. --- .../EntityTransfer/EntityTransferModule.cs | 24 +++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'OpenSim/Region/CoreModules/Framework') diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 87f0264..93a089d 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -1055,6 +1055,14 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer m_entityTransferStateMachine.UpdateInTransit(sp.UUID, AgentTransferState.CleaningUp); + // Need to signal neighbours whether child agents may need closing irrespective of whether this + // one needed closing. We also need to close child agents as quickly as possible to avoid complicated + // race conditions with rapid agent releporting (e.g. from A1 to a non-neighbour B, back + // to a neighbour A2 then off to a non-neighbour C). Closing child agents any later requires complex + // distributed checks to avoid problems in rapid reteleporting scenarios and where child agents are + // abandoned without proper close by viewer but then re-used by an incoming connection. + sp.CloseChildAgents(newRegionX, newRegionY); + // May need to logout or other cleanup AgentHasMovedAway(sp, logout); @@ -1064,17 +1072,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer // Now let's make it officially a child agent sp.MakeChildAgent(); - // May still need to signal neighbours whether child agents may need closing irrespective of whether this - // one needed closing. Neighbour regions also contain logic to prevent a close if a subsequent move or - // teleport re-established the child connection. - // - // It may be possible to also close child agents after a pause but one needs to be very careful about - // race conditions between different regions on rapid teleporting (e.g. from A1 to a non-neighbour B, back - // to a neighbour A2 then off to a non-neighbour C. Also, closing child agents early may be more compatible - // with complicated scenarios where there a mixture of V1 and V2 teleports, though this is conjecture. It's - // easier to close immediately and greatly reduce the scope of race conditions if possible. - sp.CloseChildAgents(newRegionX, newRegionY); - // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone if (NeedsClosing(sp.DrawDistance, oldRegionX, newRegionX, oldRegionY, newRegionY, reg)) { @@ -1096,7 +1093,10 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer } else { - m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Not closing agent {0}, user is back in {1}", sp.Name, Scene.Name); + m_log.DebugFormat( + "[ENTITY TRANSFER MODULE]: Connection for {0} in {1} has been re-established after teleport. Not closing.", + sp.Name, Scene.Name); + sp.DoNotCloseAfterTeleport = false; } } -- cgit v1.1