aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Framework
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules/Framework')
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs263
1 files changed, 196 insertions, 67 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
index 5124aed..b0c0b1d 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
@@ -684,7 +684,18 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
684 agentCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath(); 684 agentCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath();
685 } 685 }
686 686
687 //sp.ControllingClient.SendTeleportProgress(teleportFlags, "Contacting destination..."); 687 if (version.Equals("SIMULATION/0.2"))
688 TransferAgent_V2(sp, agentCircuit, reg, finalDestination, endPoint, teleportFlags, oldRegionX, newRegionX, oldRegionY, newRegionY, version, out reason);
689 else
690 TransferAgent_V1(sp, agentCircuit, reg, finalDestination, endPoint, teleportFlags, oldRegionX, newRegionX, oldRegionY, newRegionY, version, out reason);
691
692 }
693
694 private void TransferAgent_V1(ScenePresence sp, AgentCircuitData agentCircuit, GridRegion reg, GridRegion finalDestination,
695 IPEndPoint endPoint, uint teleportFlags, uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY, string version, out string reason)
696 {
697 ulong destinationHandle = finalDestination.RegionHandle;
698 AgentCircuitData currentAgentCircuit = sp.Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode);
688 699
689 // Let's create an agent there if one doesn't exist yet. 700 // Let's create an agent there if one doesn't exist yet.
690 // NOTE: logout will always be false for a non-HG teleport. 701 // NOTE: logout will always be false for a non-HG teleport.
@@ -707,7 +718,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
707 m_interRegionTeleportCancels.Value++; 718 m_interRegionTeleportCancels.Value++;
708 719
709 m_log.DebugFormat( 720 m_log.DebugFormat(
710 "[ENTITY TRANSFER MODULE]: Cancelled teleport of {0} to {1} from {2} after CreateAgent on client request", 721 "[ENTITY TRANSFER MODULE]: Cancelled teleport of {0} to {1} from {2} after CreateAgent on client request",
711 sp.Name, finalDestination.RegionName, sp.Scene.Name); 722 sp.Name, finalDestination.RegionName, sp.Scene.Name);
712 723
713 return; 724 return;
@@ -725,14 +736,13 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
725 736
726 // Past this point we have to attempt clean up if the teleport fails, so update transfer state. 737 // Past this point we have to attempt clean up if the teleport fails, so update transfer state.
727 m_entityTransferStateMachine.UpdateInTransit(sp.UUID, AgentTransferState.Transferring); 738 m_entityTransferStateMachine.UpdateInTransit(sp.UUID, AgentTransferState.Transferring);
728 739
729 #region old protocol 740 IClientIPEndpoint ipepClient;
730 741 string capsPath = String.Empty;
731 IClientIPEndpoint ipepClient;
732 if (NeedsNewAgent(sp.DrawDistance, oldRegionX, newRegionX, oldRegionY, newRegionY)) 742 if (NeedsNewAgent(sp.DrawDistance, oldRegionX, newRegionX, oldRegionY, newRegionY))
733 { 743 {
734 m_log.DebugFormat( 744 m_log.DebugFormat(
735 "[ENTITY TRANSFER MODULE]: Determined that region {0} at {1},{2} needs new child agent for incoming agent {3} from {4}", 745 "[ENTITY TRANSFER MODULE]: Determined that region {0} at {1},{2} needs new child agent for incoming agent {3} from {4}",
736 finalDestination.RegionName, newRegionX, newRegionY, sp.Name, Scene.Name); 746 finalDestination.RegionName, newRegionX, newRegionY, sp.Name, Scene.Name);
737 747
738 //sp.ControllingClient.SendTeleportProgress(teleportFlags, "Creating agent..."); 748 //sp.ControllingClient.SendTeleportProgress(teleportFlags, "Creating agent...");
@@ -745,30 +755,30 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
745 #endregion 755 #endregion
746 capsPath = finalDestination.ServerURI + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath); 756 capsPath = finalDestination.ServerURI + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath);
747 757
748 //if (m_eqModule != null) 758 if (m_eqModule != null)
749 //{ 759 {
750 // // The EnableSimulator message makes the client establish a connection with the destination 760 // The EnableSimulator message makes the client establish a connection with the destination
751 // // simulator by sending the initial UseCircuitCode UDP packet to the destination containing the 761 // simulator by sending the initial UseCircuitCode UDP packet to the destination containing the
752 // // correct circuit code. 762 // correct circuit code.
753 // m_eqModule.EnableSimulator(destinationHandle, endPoint, sp.UUID); 763 m_eqModule.EnableSimulator(destinationHandle, endPoint, sp.UUID);
754 764
755 // // XXX: Is this wait necessary? We will always end up waiting on UpdateAgent for the destination 765 // XXX: Is this wait necessary? We will always end up waiting on UpdateAgent for the destination
756 // // simulator to confirm that it has established communication with the viewer. 766 // simulator to confirm that it has established communication with the viewer.
757 // Thread.Sleep(200); 767 Thread.Sleep(200);
758 768
759 // // At least on LL 3.3.4 for teleports between different regions on the same simulator this appears 769 // At least on LL 3.3.4 for teleports between different regions on the same simulator this appears
760 // // unnecessary - teleport will succeed and SEED caps will be requested without it (though possibly 770 // unnecessary - teleport will succeed and SEED caps will be requested without it (though possibly
761 // // only on TeleportFinish). This is untested for region teleport between different simulators 771 // only on TeleportFinish). This is untested for region teleport between different simulators
762 // // though this probably also works. 772 // though this probably also works.
763 // m_eqModule.EstablishAgentCommunication(sp.UUID, endPoint, capsPath); 773 m_eqModule.EstablishAgentCommunication(sp.UUID, endPoint, capsPath);
764 //} 774 }
765 //else 775 else
766 //{ 776 {
767 // // XXX: This is a little misleading since we're information the client of its avatar destination, 777 // XXX: This is a little misleading since we're information the client of its avatar destination,
768 // // which may or may not be a neighbour region of the source region. This path is probably little 778 // which may or may not be a neighbour region of the source region. This path is probably little
769 // // used anyway (with EQ being the one used). But it is currently being used for test code. 779 // used anyway (with EQ being the one used). But it is currently being used for test code.
770 // sp.ControllingClient.InformClientOfNeighbour(destinationHandle, endPoint); 780 sp.ControllingClient.InformClientOfNeighbour(destinationHandle, endPoint);
771 //} 781 }
772 } 782 }
773 else 783 else
774 { 784 {
@@ -776,15 +786,12 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
776 capsPath = finalDestination.ServerURI + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath); 786 capsPath = finalDestination.ServerURI + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath);
777 } 787 }
778 788
779 #endregion old protocol
780
781 // Let's send a full update of the agent. This is a synchronous call. 789 // Let's send a full update of the agent. This is a synchronous call.
782 AgentData agent = new AgentData(); 790 AgentData agent = new AgentData();
783 sp.CopyTo(agent); 791 sp.CopyTo(agent);
784 agent.Position = position; 792 agent.Position = agentCircuit.startpos;
785 //SetCallbackURL(agent, sp.Scene.RegionInfo); 793 SetCallbackURL(agent, sp.Scene.RegionInfo);
786 794
787 //sp.ControllingClient.SendTeleportProgress(teleportFlags, "Updating agent...");
788 795
789 // We will check for an abort before UpdateAgent since UpdateAgent will require an active viewer to 796 // We will check for an abort before UpdateAgent since UpdateAgent will require an active viewer to
790 // establish th econnection to the destination which makes it return true. 797 // establish th econnection to the destination which makes it return true.
@@ -814,7 +821,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
814 sp.ControllingClient.SendRegionTeleport(destinationHandle, 13, endPoint, 4, 821 sp.ControllingClient.SendRegionTeleport(destinationHandle, 13, endPoint, 4,
815 teleportFlags, capsPath); 822 teleportFlags, capsPath);
816 } 823 }
817 824
818 // A common teleport failure occurs when we can send CreateAgent to the 825 // A common teleport failure occurs when we can send CreateAgent to the
819 // destination region but the viewer cannot establish the connection (e.g. due to network issues between 826 // destination region but the viewer cannot establish the connection (e.g. due to network issues between
820 // the viewer and the destination). In this case, UpdateAgent timesout after 10 seconds, although then 827 // the viewer and the destination). In this case, UpdateAgent timesout after 10 seconds, although then
@@ -835,7 +842,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
835 m_log.WarnFormat( 842 m_log.WarnFormat(
836 "[ENTITY TRANSFER MODULE]: UpdateAgent failed on teleport of {0} to {1} from {2}. Keeping avatar in source region.", 843 "[ENTITY TRANSFER MODULE]: UpdateAgent failed on teleport of {0} to {1} from {2}. Keeping avatar in source region.",
837 sp.Name, finalDestination.RegionName, sp.Scene.RegionInfo.RegionName); 844 sp.Name, finalDestination.RegionName, sp.Scene.RegionInfo.RegionName);
838 845
839 Fail(sp, finalDestination, logout, currentAgentCircuit.SessionID.ToString(), "Connection between viewer and destination region could not be established."); 846 Fail(sp, finalDestination, logout, currentAgentCircuit.SessionID.ToString(), "Connection between viewer and destination region could not be established.");
840 return; 847 return;
841 } 848 }
@@ -845,7 +852,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
845 m_interRegionTeleportCancels.Value++; 852 m_interRegionTeleportCancels.Value++;
846 853
847 m_log.DebugFormat( 854 m_log.DebugFormat(
848 "[ENTITY TRANSFER MODULE]: Cancelled teleport of {0} to {1} from {2} after UpdateAgent on client request", 855 "[ENTITY TRANSFER MODULE]: Cancelled teleport of {0} to {1} from {2} after UpdateAgent on client request",
849 sp.Name, finalDestination.RegionName, sp.Scene.Name); 856 sp.Name, finalDestination.RegionName, sp.Scene.Name);
850 857
851 CleanupFailedInterRegionTeleport(sp, currentAgentCircuit.SessionID.ToString(), finalDestination); 858 CleanupFailedInterRegionTeleport(sp, currentAgentCircuit.SessionID.ToString(), finalDestination);
@@ -857,30 +864,30 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
857 "[ENTITY TRANSFER MODULE]: Sending new CAPS seed url {0} from {1} to {2}", 864 "[ENTITY TRANSFER MODULE]: Sending new CAPS seed url {0} from {1} to {2}",
858 capsPath, sp.Scene.RegionInfo.RegionName, sp.Name); 865 capsPath, sp.Scene.RegionInfo.RegionName, sp.Name);
859 866
860 //// TeleportFinish makes the client send CompleteMovementIntoRegion (at the destination), which 867 // TeleportFinish makes the client send CompleteMovementIntoRegion (at the destination), which
861 //// trigers a whole shebang of things there, including MakeRoot. So let's wait for confirmation 868 // trigers a whole shebang of things there, including MakeRoot. So let's wait for confirmation
862 //// that the client contacted the destination before we close things here. 869 // that the client contacted the destination before we close things here.
863 //if (!m_entityTransferStateMachine.WaitForAgentArrivedAtDestination(sp.UUID)) 870 if (!m_entityTransferStateMachine.WaitForAgentArrivedAtDestination(sp.UUID))
864 //{ 871 {
865 // if (m_entityTransferStateMachine.GetAgentTransferState(sp.UUID) == AgentTransferState.Aborting) 872 if (m_entityTransferStateMachine.GetAgentTransferState(sp.UUID) == AgentTransferState.Aborting)
866 // { 873 {
867 // m_interRegionTeleportAborts.Value++; 874 m_interRegionTeleportAborts.Value++;
868
869 // m_log.DebugFormat(
870 // "[ENTITY TRANSFER MODULE]: Aborted teleport of {0} to {1} from {2} after WaitForAgentArrivedAtDestination due to previous client close.",
871 // sp.Name, finalDestination.RegionName, sp.Scene.Name);
872
873 // return;
874 // }
875
876 // m_log.WarnFormat(
877 // "[ENTITY TRANSFER MODULE]: Teleport of {0} to {1} from {2} failed due to no callback from destination region. Returning avatar to source region.",
878 // sp.Name, finalDestination.RegionName, sp.Scene.RegionInfo.RegionName);
879
880 // Fail(sp, finalDestination, logout, currentAgentCircuit.SessionID.ToString(), "Destination region did not signal teleport completion.");
881 875
882 // return; 876 m_log.DebugFormat(
883 //} 877 "[ENTITY TRANSFER MODULE]: Aborted teleport of {0} to {1} from {2} after WaitForAgentArrivedAtDestination due to previous client close.",
878 sp.Name, finalDestination.RegionName, sp.Scene.Name);
879
880 return;
881 }
882
883 m_log.WarnFormat(
884 "[ENTITY TRANSFER MODULE]: Teleport of {0} to {1} from {2} failed due to no callback from destination region. Returning avatar to source region.",
885 sp.Name, finalDestination.RegionName, sp.Scene.RegionInfo.RegionName);
886
887 Fail(sp, finalDestination, logout, currentAgentCircuit.SessionID.ToString(), "Destination region did not signal teleport completion.");
888
889 return;
890 }
884 891
885 m_entityTransferStateMachine.UpdateInTransit(sp.UUID, AgentTransferState.CleaningUp); 892 m_entityTransferStateMachine.UpdateInTransit(sp.UUID, AgentTransferState.CleaningUp);
886 893
@@ -914,7 +921,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
914 // 921 //
915 // This sleep can be increased if necessary. However, whilst it's active, 922 // This sleep can be increased if necessary. However, whilst it's active,
916 // an agent cannot teleport back to this region if it has teleported away. 923 // an agent cannot teleport back to this region if it has teleported away.
917 Thread.Sleep(15000); 924 Thread.Sleep(2000);
918 925
919 sp.Scene.IncomingCloseAgent(sp.UUID, false); 926 sp.Scene.IncomingCloseAgent(sp.UUID, false);
920 } 927 }
@@ -925,6 +932,126 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
925 } 932 }
926 } 933 }
927 934
935 private void TransferAgent_V2(ScenePresence sp, AgentCircuitData agentCircuit, GridRegion reg, GridRegion finalDestination,
936 IPEndPoint endPoint, uint teleportFlags, uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY, string version, out string reason)
937 {
938 ulong destinationHandle = finalDestination.RegionHandle;
939 AgentCircuitData currentAgentCircuit = sp.Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode);
940
941 // Let's create an agent there if one doesn't exist yet.
942 // NOTE: logout will always be false for a non-HG teleport.
943 bool logout = false;
944 if (!CreateAgent(sp, reg, finalDestination, agentCircuit, teleportFlags, out reason, out logout))
945 {
946 m_interRegionTeleportFailures.Value++;
947
948 sp.ControllingClient.SendTeleportFailed(String.Format("Teleport refused: {0}", reason));
949
950 m_log.DebugFormat(
951 "[ENTITY TRANSFER MODULE]: Teleport of {0} from {1} to {2} was refused because {3}",
952 sp.Name, sp.Scene.RegionInfo.RegionName, finalDestination.RegionName, reason);
953
954 return;
955 }
956
957 // Past this point we have to attempt clean up if the teleport fails, so update transfer state.
958 m_entityTransferStateMachine.UpdateInTransit(sp.UUID, AgentTransferState.Transferring);
959
960 IClientIPEndpoint ipepClient;
961 string capsPath = String.Empty;
962 if (NeedsNewAgent(sp.DrawDistance, oldRegionX, newRegionX, oldRegionY, newRegionY))
963 {
964 m_log.DebugFormat(
965 "[ENTITY TRANSFER MODULE]: Determined that region {0} at {1},{2} needs new child agent for agent {3} from {4}",
966 finalDestination.RegionName, newRegionX, newRegionY, sp.Name, Scene.Name);
967
968 //sp.ControllingClient.SendTeleportProgress(teleportFlags, "Creating agent...");
969 #region IP Translation for NAT
970 // Uses ipepClient above
971 if (sp.ClientView.TryGet(out ipepClient))
972 {
973 endPoint.Address = NetworkUtil.GetIPFor(ipepClient.EndPoint, endPoint.Address);
974 }
975 #endregion
976 capsPath = finalDestination.ServerURI + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath);
977 }
978 else
979 {
980 agentCircuit.CapsPath = sp.Scene.CapsModule.GetChildSeed(sp.UUID, reg.RegionHandle);
981 capsPath = finalDestination.ServerURI + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath);
982 }
983
984 // We need to set this here to avoid an unlikely race condition when teleporting to a neighbour simulator,
985 // where that neighbour simulator could otherwise request a child agent create on the source which then
986 // closes our existing agent which is still signalled as root.
987 //sp.IsChildAgent = true;
988
989 // New protocol: send TP Finish directly, without prior ES or EAC. That's what happens in the Linden grid
990 if (m_eqModule != null)
991 m_eqModule.TeleportFinishEvent(destinationHandle, 13, endPoint, 0, teleportFlags, capsPath, sp.UUID);
992 else
993 sp.ControllingClient.SendRegionTeleport(destinationHandle, 13, endPoint, 4,
994 teleportFlags, capsPath);
995
996 m_log.DebugFormat(
997 "[ENTITY TRANSFER MODULE]: Sending new CAPS seed url {0} from {1} to {2}",
998 capsPath, sp.Scene.RegionInfo.RegionName, sp.Name);
999
1000 // Let's send a full update of the agent.
1001 AgentData agent = new AgentData();
1002 sp.CopyTo(agent);
1003 agent.Position = agentCircuit.startpos;
1004 agent.SenderWantsToWaitForRoot = true;
1005 //SetCallbackURL(agent, sp.Scene.RegionInfo);
1006
1007 // Send the Update. If this returns true, we know the client has contacted the destination
1008 // via CompleteMovementIntoRegion, so we can let go.
1009 // If it returns false, something went wrong, and we need to abort.
1010 m_log.DebugFormat("[ZZZ]: Sending Update");
1011 if (!UpdateAgent(reg, finalDestination, agent, sp))
1012 {
1013 if (m_entityTransferStateMachine.GetAgentTransferState(sp.UUID) == AgentTransferState.Aborting)
1014 {
1015 m_interRegionTeleportAborts.Value++;
1016
1017 m_log.DebugFormat(
1018 "[ENTITY TRANSFER MODULE]: Aborted teleport of {0} to {1} from {2} after UpdateAgent due to previous client close.",
1019 sp.Name, finalDestination.RegionName, sp.Scene.Name);
1020
1021 return;
1022 }
1023
1024 m_log.WarnFormat(
1025 "[ENTITY TRANSFER MODULE]: UpdateAgent failed on teleport of {0} to {1} from {2}. Keeping avatar in source region.",
1026 sp.Name, finalDestination.RegionName, sp.Scene.RegionInfo.RegionName);
1027
1028 Fail(sp, finalDestination, logout, currentAgentCircuit.SessionID.ToString(), "Connection between viewer and destination region could not be established.");
1029 return;
1030 }
1031
1032 m_entityTransferStateMachine.UpdateInTransit(sp.UUID, AgentTransferState.CleaningUp);
1033
1034 // May need to logout or other cleanup
1035 AgentHasMovedAway(sp, logout);
1036
1037 // Well, this is it. The agent is over there.
1038 KillEntity(sp.Scene, sp.LocalId);
1039
1040 // Now let's make it officially a child agent
1041 sp.MakeChildAgent();
1042
1043 // OK, it got this agent. Let's close some child agents
1044 sp.CloseChildAgents(newRegionX, newRegionY);
1045
1046 // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone
1047
1048 if (NeedsClosing(sp.DrawDistance, oldRegionX, newRegionX, oldRegionY, newRegionY, reg))
1049 sp.Scene.IncomingCloseAgent(sp.UUID, false);
1050 else
1051 // now we have a child agent in this region.
1052 sp.Reset();
1053 }
1054
928 /// <summary> 1055 /// <summary>
929 /// Clean up an inter-region teleport that did not complete, either because of simulator failure or cancellation. 1056 /// Clean up an inter-region teleport that did not complete, either because of simulator failure or cancellation.
930 /// </summary> 1057 /// </summary>
@@ -938,11 +1065,13 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
938 { 1065 {
939 m_entityTransferStateMachine.UpdateInTransit(sp.UUID, AgentTransferState.CleaningUp); 1066 m_entityTransferStateMachine.UpdateInTransit(sp.UUID, AgentTransferState.CleaningUp);
940 1067
941 sp.IsChildAgent = false; 1068 if (sp.IsChildAgent) // We had set it to child before attempted TP (V1)
942 ReInstantiateScripts(sp); 1069 {
943 1070 sp.IsChildAgent = false;
944 EnableChildAgents(sp); 1071 ReInstantiateScripts(sp);
945 1072
1073 EnableChildAgents(sp);
1074 }
946 // Finally, kill the agent we just created at the destination. 1075 // Finally, kill the agent we just created at the destination.
947 // XXX: Possibly this should be done asynchronously. 1076 // XXX: Possibly this should be done asynchronously.
948 Scene.SimulationService.CloseAgent(finalDestination, sp.UUID, auth_token); 1077 Scene.SimulationService.CloseAgent(finalDestination, sp.UUID, auth_token);