aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs
diff options
context:
space:
mode:
authorBrian McBee2008-01-20 19:12:00 +0000
committerBrian McBee2008-01-20 19:12:00 +0000
commit730e2d6d7c0e6ddc6448c4b6064498294134d67f (patch)
treed26706e6361599b8cadc49eac59ba281fe459755 /OpenSim/Region/Communications/OGS1/OGS1GridServices.cs
parentTedds temp fix for startup crash: Waiting 3 seconds for stuff to catch up. (S... (diff)
downloadopensim-SC_OLD-730e2d6d7c0e6ddc6448c4b6064498294134d67f.zip
opensim-SC_OLD-730e2d6d7c0e6ddc6448c4b6064498294134d67f.tar.gz
opensim-SC_OLD-730e2d6d7c0e6ddc6448c4b6064498294134d67f.tar.bz2
opensim-SC_OLD-730e2d6d7c0e6ddc6448c4b6064498294134d67f.tar.xz
Check if remote simulator is up before attempting teleport. Teleport to a remote region should now fail gracefully if remote simulator is down.
Diffstat (limited to 'OpenSim/Region/Communications/OGS1/OGS1GridServices.cs')
-rw-r--r--OpenSim/Region/Communications/OGS1/OGS1GridServices.cs77
1 files changed, 58 insertions, 19 deletions
diff --git a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs
index e3d10b5..78dca09 100644
--- a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs
+++ b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs
@@ -594,28 +594,31 @@ namespace OpenSim.Region.Communications.OGS1
594 //don't want to be creating a new link to the remote instance every time like we are here 594 //don't want to be creating a new link to the remote instance every time like we are here
595 bool retValue = false; 595 bool retValue = false;
596 596
597 checkRegion(regInfo.RemotingAddress, regInfo.RemotingPort);
598 if (Available)
599 {
600 OGS1InterRegionRemoting remObject = (OGS1InterRegionRemoting)Activator.GetObject(
601 typeof(OGS1InterRegionRemoting),
602 "tcp://" + regInfo.RemotingAddress +
603 ":" + regInfo.RemotingPort +
604 "/InterRegions");
597 605
598 OGS1InterRegionRemoting remObject = (OGS1InterRegionRemoting) Activator.GetObject( 606 if (remObject != null)
599 typeof (OGS1InterRegionRemoting), 607 {
600 "tcp://" + regInfo.RemotingAddress + 608 retValue = remObject.InformRegionOfChildAgent(regionHandle, new sAgentCircuitData(agentData));
601 ":" + regInfo.RemotingPort + 609 }
602 "/InterRegions"); 610 else
611 {
612 Console.WriteLine("remoting object not found");
613 }
614 remObject = null;
615 MainLog.Instance.Verbose("INTER",
616 gdebugRegionName + ": OGS1 tried to InformRegionOfChildAgent for " +
617 agentData.firstname + " " + agentData.lastname + " and got " +
618 retValue.ToString());
603 619
604 if (remObject != null) 620 return retValue;
605 {
606 retValue = remObject.InformRegionOfChildAgent(regionHandle, new sAgentCircuitData(agentData));
607 }
608 else
609 {
610 Console.WriteLine("remoting object not found");
611 } 621 }
612 remObject = null;
613 MainLog.Instance.Verbose("INTER",
614 gdebugRegionName + ": OGS1 tried to InformRegionOfChildAgent for " +
615 agentData.firstname + " " + agentData.lastname + " and got " +
616 retValue.ToString());
617
618 return retValue;
619 } 622 }
620 623
621 return false; 624 return false;
@@ -1085,5 +1088,41 @@ namespace OpenSim.Region.Communications.OGS1
1085 #endregion 1088 #endregion
1086 1089
1087 #endregion 1090 #endregion
1091
1092 // helper to see if remote region is up
1093 bool m_bAvailable = false;
1094 int timeOut = 15000; //15 seconds
1095
1096 public void checkRegion(string address, uint port)
1097 {
1098 IPAddress ia = null;
1099 IPAddress.TryParse(address, out ia);
1100 IPEndPoint m_EndPoint = new IPEndPoint(ia, (int)port);
1101 AsyncCallback ConnectedMethodCallback = new AsyncCallback(ConnectedMethod);
1102 Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
1103 IAsyncResult ar = socket.BeginConnect(m_EndPoint, ConnectedMethodCallback, socket);
1104 ar.AsyncWaitHandle.WaitOne(timeOut, false);
1105 socket.Close();
1106 }
1107
1108 public bool Available
1109 {
1110 get { return m_bAvailable; }
1111 }
1112
1113 void ConnectedMethod(IAsyncResult ar)
1114 {
1115 Socket socket = (Socket)ar.AsyncState;
1116 try
1117 {
1118 socket.EndConnect(ar);
1119 m_bAvailable = true;
1120 }
1121 catch (Exception)
1122 {
1123 }
1124 socket.Close();
1125 }
1088 } 1126 }
1127
1089} \ No newline at end of file 1128} \ No newline at end of file