From 33330297d603a66cc157baa21c81328edc893e51 Mon Sep 17 00:00:00 2001 From: diva Date: Fri, 20 Feb 2009 03:39:50 +0000 Subject: THE BIG ANTI-REMOTING SCHLEP -- StartRemoting is no more. Sims in older versions will have a hard time communicating with sims on this release and later, especially if they haven't transitioned to RESTComms at all. There's still some cleanup to do on assorted data structures, but the main functional change here is that sims no longer listen on remoting ports. --- .../Hypergrid/HGGridServicesStandalone.cs | 679 --------------------- 1 file changed, 679 deletions(-) (limited to 'OpenSim/Region/Communications/Hypergrid/HGGridServicesStandalone.cs') diff --git a/OpenSim/Region/Communications/Hypergrid/HGGridServicesStandalone.cs b/OpenSim/Region/Communications/Hypergrid/HGGridServicesStandalone.cs index ea8ac2e..36d4b99 100644 --- a/OpenSim/Region/Communications/Hypergrid/HGGridServicesStandalone.cs +++ b/OpenSim/Region/Communications/Hypergrid/HGGridServicesStandalone.cs @@ -84,7 +84,6 @@ namespace OpenSim.Region.Communications.Hypergrid httpServer.AddXmlRPCHandler("check", PingCheckReply); httpServer.AddXmlRPCHandler("land_data", LandData); - StartRemoting(); } #region IGridServices interface @@ -256,683 +255,5 @@ namespace OpenSim.Region.Communications.Hypergrid #endregion - #region Remoting - - /// - /// Start listening for .net remoting calls from other regions. - /// - private void StartRemoting() - { - m_log.Info("[HGrid]: Start remoting..."); - TcpChannel ch; - try - { - ch = new TcpChannel((int)NetworkServersInfo.RemotingListenerPort); - ChannelServices.RegisterChannel(ch, false); // Disabled security as Mono doesn't support this. - } - catch (Exception ex) - { - m_log.Error("[HGrid]: Exception while attempting to listen on TCP port " + (int)NetworkServersInfo.RemotingListenerPort + "."); - throw (ex); - } - - WellKnownServiceTypeEntry wellType = - new WellKnownServiceTypeEntry(typeof(OGS1InterRegionRemoting), "InterRegions", - WellKnownObjectMode.Singleton); - RemotingConfiguration.RegisterWellKnownServiceType(wellType); - InterRegionSingleton.Instance.OnArrival += TriggerExpectAvatarCrossing; - InterRegionSingleton.Instance.OnChildAgent += IncomingChildAgent; - InterRegionSingleton.Instance.OnPrimGroupArrival += IncomingPrim; - InterRegionSingleton.Instance.OnPrimGroupNear += TriggerExpectPrimCrossing; - InterRegionSingleton.Instance.OnRegionUp += TriggerRegionUp; - InterRegionSingleton.Instance.OnChildAgentUpdate += TriggerChildAgentUpdate; - InterRegionSingleton.Instance.OnTellRegionToCloseChildConnection += TriggerTellRegionToCloseChildConnection; - } - - - #endregion - - #region IInterRegionCommunications interface (Methods called by regions in this instance) - - public override bool ChildAgentUpdate(ulong regionHandle, ChildAgentDataUpdate cAgentData) - { - int failures = 0; - lock (m_deadRegionCache) - { - if (m_deadRegionCache.ContainsKey(regionHandle)) - { - failures = m_deadRegionCache[regionHandle]; - } - } - if (failures <= 3) - { - RegionInfo regInfo = null; - try - { - if (m_localBackend.ChildAgentUpdate(regionHandle, cAgentData)) - { - return true; - } - - regInfo = RequestNeighbourInfo(regionHandle); - if (regInfo != null) - { - //don't want to be creating a new link to the remote instance every time like we are here - bool retValue = false; - - - OGS1InterRegionRemoting remObject = (OGS1InterRegionRemoting)Activator.GetObject( - typeof(OGS1InterRegionRemoting), - "tcp://" + regInfo.RemotingAddress + - ":" + regInfo.RemotingPort + - "/InterRegions"); - - if (remObject != null) - { - retValue = remObject.ChildAgentUpdate(regionHandle, cAgentData); - } - else - { - m_log.Warn("[HGrid]: remoting object not found"); - } - remObject = null; - - return retValue; - } - NoteDeadRegion(regionHandle); - - return false; - } - catch (RemotingException e) - { - NoteDeadRegion(regionHandle); - - m_log.WarnFormat( - "[HGrid]: Remoting Error: Unable to connect to adjacent region: {0} {1},{2}", - regInfo.RegionName, regInfo.RegionLocX, regInfo.RegionLocY); - m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); - - return false; - } - catch (SocketException e) - { - NoteDeadRegion(regionHandle); - - m_log.WarnFormat( - "[HGrid]: Remoting Error: Unable to connect to adjacent region: {0} {1},{2}", - regInfo.RegionName, regInfo.RegionLocX, regInfo.RegionLocY); - m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); - - return false; - } - catch (InvalidCredentialException e) - { - NoteDeadRegion(regionHandle); - - m_log.WarnFormat( - "[HGrid]: Remoting Error: Unable to connect to adjacent region: {0} {1},{2}", - regInfo.RegionName, regInfo.RegionLocX, regInfo.RegionLocY); - m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); - - return false; - } - catch (AuthenticationException e) - { - NoteDeadRegion(regionHandle); - - m_log.WarnFormat( - "[HGrid]: Remoting Error: Unable to connect to adjacent region: {0} {1},{2}", - regInfo.RegionName, regInfo.RegionLocX, regInfo.RegionLocY); - m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); - - return false; - } - catch (Exception e) - { - NoteDeadRegion(regionHandle); - - m_log.WarnFormat("[HGrid]: Unable to connect to adjacent region: {0} {1},{2}", - regInfo.RegionName, regInfo.RegionLocX, regInfo.RegionLocY); - m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); - - return false; - } - } - else - { - //m_log.Info("[INTERREGION]: Skipped Sending Child Update to a region because it failed too many times:" + regionHandle.ToString()); - return false; - } - } - - /// - /// Inform a region that a child agent will be on the way from a client. - /// - /// - /// - /// - public override bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData) - { - - if (m_localBackend.InformRegionOfChildAgent(regionHandle, agentData)) - { - return true; - } - return base.InformRegionOfChildAgent(regionHandle, agentData); - } - - // UGLY! - public override bool RegionUp(SerializableRegionInfo region, ulong regionhandle) - { - if (m_localBackend.RegionUp(region, regionhandle)) - return true; - return base.RegionUp(region, regionhandle); - } - - /// - /// - /// - /// - /// - /// - public override bool InformRegionOfPrimCrossing(ulong regionHandle, UUID primID, string objData, int XMLMethod) - { - int failures = 0; - lock (m_deadRegionCache) - { - if (m_deadRegionCache.ContainsKey(regionHandle)) - { - failures = m_deadRegionCache[regionHandle]; - } - } - if (failures <= 1) - { - RegionInfo regInfo = null; - try - { - if (m_localBackend.InformRegionOfPrimCrossing(regionHandle, primID, objData, XMLMethod)) - { - return true; - } - - regInfo = RequestNeighbourInfo(regionHandle); - if (regInfo != null) - { - try - { - regionHandle = Convert.ToUInt64(regInfo.regionSecret); - } - catch (Exception) - { - m_log.Warn("[HGrid]: Invalid hyperlink region."); - return false; - } - - //don't want to be creating a new link to the remote instance every time like we are here - bool retValue = false; - - OGS1InterRegionRemoting remObject = (OGS1InterRegionRemoting)Activator.GetObject( - typeof(OGS1InterRegionRemoting), - "tcp://" + regInfo.RemotingAddress + - ":" + regInfo.RemotingPort + - "/InterRegions"); - - if (remObject != null) - { - m_log.Debug("[HGrid]: Inform region of prim crossing: " + regInfo.RemotingAddress + ":" + regInfo.RemotingPort); - retValue = remObject.InformRegionOfPrimCrossing(regionHandle, primID.Guid, objData, XMLMethod); - } - else - { - m_log.Warn("[HGrid]: Remoting object not found"); - } - remObject = null; - - return retValue; - } - NoteDeadRegion(regionHandle); - return false; - } - catch (RemotingException e) - { - NoteDeadRegion(regionHandle); - m_log.Warn("[HGrid]: Remoting Error: Unable to connect to adjacent region: " + regionHandle); - m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); - return false; - } - catch (SocketException e) - { - NoteDeadRegion(regionHandle); - m_log.Warn("[HGrid]: Remoting Error: Unable to connect to adjacent region: " + regionHandle); - m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); - return false; - } - catch (InvalidCredentialException e) - { - NoteDeadRegion(regionHandle); - m_log.Warn("[HGrid]: Invalid Credential Exception: Invalid Credentials : " + regionHandle); - m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); - return false; - } - catch (AuthenticationException e) - { - NoteDeadRegion(regionHandle); - m_log.Warn("[HGrid]: Authentication exception: Unable to connect to adjacent region: " + regionHandle); - m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); - return false; - } - catch (Exception e) - { - NoteDeadRegion(regionHandle); - m_log.Warn("[HGrid]: Unknown exception: Unable to connect to adjacent region: " + regionHandle); - m_log.DebugFormat("[HGrid]: {0}", e); - return false; - } - } - else - { - return false; - } - } - - /// - /// - /// - /// - /// - /// - /// - public override bool ExpectAvatarCrossing(ulong regionHandle, UUID agentID, Vector3 position, bool isFlying) - { - - RegionInfo[] regions = m_regionsOnInstance.ToArray(); - bool banned = false; - bool localregion = false; - - for (int i = 0; i < regions.Length; i++) - { - if (regions[i] != null) - { - if (regions[i].RegionHandle == regionHandle) - { - localregion = true; - if (regions[i].EstateSettings.IsBanned(agentID)) - { - banned = true; - break; - } - } - } - } - - if (banned) - return false; - if (localregion) - return m_localBackend.ExpectAvatarCrossing(regionHandle, agentID, position, isFlying); - - return base.ExpectAvatarCrossing(regionHandle, agentID, position, isFlying); - - } - - public override bool ExpectPrimCrossing(ulong regionHandle, UUID agentID, Vector3 position, bool isPhysical) - { - RegionInfo regInfo = null; - try - { - if (m_localBackend.TriggerExpectPrimCrossing(regionHandle, agentID, position, isPhysical)) - { - return true; - } - - regInfo = RequestNeighbourInfo(regionHandle); - if (regInfo != null) - { - bool retValue = false; - OGS1InterRegionRemoting remObject = (OGS1InterRegionRemoting)Activator.GetObject( - typeof(OGS1InterRegionRemoting), - "tcp://" + regInfo.RemotingAddress + - ":" + regInfo.RemotingPort + - "/InterRegions"); - - if (remObject != null) - { - retValue = - remObject.ExpectAvatarCrossing(regionHandle, agentID.Guid, new sLLVector3(position), - isPhysical); - } - else - { - m_log.Warn("[HGrid]: Remoting object not found"); - } - remObject = null; - - return retValue; - } - //TODO need to see if we know about where this region is and use .net remoting - // to inform it. - NoteDeadRegion(regionHandle); - return false; - } - catch (RemotingException e) - { - NoteDeadRegion(regionHandle); - m_log.Warn("[HGrid]: Remoting Error: Unable to connect to adjacent region: " + regionHandle); - m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); - return false; - } - catch (SocketException e) - { - NoteDeadRegion(regionHandle); - m_log.Warn("[HGrid]: Remoting Error: Unable to connect to adjacent region: " + regionHandle); - m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); - return false; - } - catch (InvalidCredentialException e) - { - NoteDeadRegion(regionHandle); - m_log.Warn("[HGrid]: Invalid Credential Exception: Invalid Credentials : " + regionHandle); - m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); - return false; - } - catch (AuthenticationException e) - { - NoteDeadRegion(regionHandle); - m_log.Warn("[HGrid]: Authentication exception: Unable to connect to adjacent region: " + regionHandle); - m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); - return false; - } - catch (Exception e) - { - NoteDeadRegion(regionHandle); - m_log.Warn("[HGrid]: Unknown exception: Unable to connect to adjacent region: " + regionHandle); - m_log.DebugFormat("[HGrid]: {0}", e); - return false; - } - } - - public override bool TellRegionToCloseChildConnection(ulong regionHandle, UUID agentID) - { - m_log.Debug("[HGrid]: TellRegion " + regionHandle + " ToCloseChildConnection for " + agentID); - RegionInfo regInfo = null; - try - { - if (m_localBackend.TriggerTellRegionToCloseChildConnection(regionHandle, agentID)) - { - return true; - } - - regInfo = RequestNeighbourInfo(regionHandle); - if (regInfo != null) - { - // bool retValue = false; - OGS1InterRegionRemoting remObject = (OGS1InterRegionRemoting)Activator.GetObject( - typeof(OGS1InterRegionRemoting), - "tcp://" + regInfo.RemotingAddress + - ":" + regInfo.RemotingPort + - "/InterRegions"); - - if (remObject != null) - { - // retValue = - remObject.TellRegionToCloseChildConnection(regionHandle, agentID.Guid); - } - else - { - m_log.Warn("[HGrid]: Remoting object not found"); - } - remObject = null; - - return true; - } - //TODO need to see if we know about where this region is and use .net remoting - // to inform it. - NoteDeadRegion(regionHandle); - return false; - } - catch (RemotingException) - { - NoteDeadRegion(regionHandle); - m_log.Warn("[HGrid]: Remoting Error: Unable to connect to adjacent region to tell it to close child agents: " + regInfo.RegionName + - " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); - //m_log.Debug(e.ToString()); - return false; - } - catch (SocketException e) - { - NoteDeadRegion(regionHandle); - m_log.Warn("[HGridS]: Socket Error: Unable to connect to adjacent region using tcp://" + - regInfo.RemotingAddress + - ":" + regInfo.RemotingPort + - "/InterRegions - @ " + regInfo.RegionLocX + "," + regInfo.RegionLocY + - " - Is this neighbor up?"); - m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); - return false; - } - catch (InvalidCredentialException e) - { - NoteDeadRegion(regionHandle); - m_log.Warn("[HGrid]: Invalid Credentials: Unable to connect to adjacent region using tcp://" + - regInfo.RemotingAddress + - ":" + regInfo.RemotingPort + - "/InterRegions - @ " + regInfo.RegionLocX + "," + regInfo.RegionLocY); - m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); - return false; - } - catch (AuthenticationException e) - { - NoteDeadRegion(regionHandle); - m_log.Warn("[HGrid]: Authentication exception: Unable to connect to adjacent region using tcp://" + - regInfo.RemotingAddress + - ":" + regInfo.RemotingPort + - "/InterRegions - @ " + regInfo.RegionLocX + "," + regInfo.RegionLocY); - m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); - return false; - } - catch (WebException e) - { - NoteDeadRegion(regionHandle); - m_log.Warn("[HGrid]: WebException exception: Unable to connect to adjacent region using tcp://" + - regInfo.RemotingAddress + - ":" + regInfo.RemotingPort + - "/InterRegions - @ " + regInfo.RegionLocX + "," + regInfo.RegionLocY); - m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); - return false; - } - catch (Exception e) - { - NoteDeadRegion(regionHandle); - // This line errors with a Null Reference Exception.. Why? @.@ - //m_log.Warn("Unknown exception: Unable to connect to adjacent region using tcp://" + regInfo.RemotingAddress + - // ":" + regInfo.RemotingPort + - //"/InterRegions - @ " + regInfo.RegionLocX + "," + regInfo.RegionLocY + " - This is likely caused by an incompatibility in the protocol between this sim and that one"); - m_log.DebugFormat("[HGrid]: {0}", e); - return false; - } - } - - public override bool AcknowledgeAgentCrossed(ulong regionHandle, UUID agentId) - { - return m_localBackend.AcknowledgeAgentCrossed(regionHandle, agentId); - } - - public override bool AcknowledgePrimCrossed(ulong regionHandle, UUID primId) - { - return m_localBackend.AcknowledgePrimCrossed(regionHandle, primId); - } - - #endregion - - #region Methods triggered by calls from external instances - - /// - /// - /// - /// - /// - /// - public bool IncomingChildAgent(ulong regionHandle, AgentCircuitData agentData) - { - AdjustUserInformation(agentData); - - m_log.Info("[HGrid]: " + gdebugRegionName + ": Incoming HGrid Agent " + agentData.firstname + " " + agentData.lastname); - - return m_localBackend.IncomingChildAgent(regionHandle, agentData); - } - - public bool TriggerRegionUp(RegionUpData regionData, ulong regionhandle) - { - m_log.Info( - "[HGrid]: " + - m_localBackend._gdebugRegionName + "Incoming HGrid RegionUpReport: " + "(" + regionData.X + - "," + regionData.Y + "). Giving this region a fresh set of 'dead' tries"); - - RegionInfo nRegionInfo = new RegionInfo(); - nRegionInfo.SetEndPoint("127.0.0.1", regionData.PORT); - nRegionInfo.ExternalHostName = regionData.IPADDR; - nRegionInfo.RegionLocX = regionData.X; - nRegionInfo.RegionLocY = regionData.Y; - - lock (m_deadRegionCache) - { - if (m_deadRegionCache.ContainsKey(nRegionInfo.RegionHandle)) - { - m_deadRegionCache.Remove(nRegionInfo.RegionHandle); - } - } - - return m_localBackend.TriggerRegionUp(nRegionInfo, regionhandle); - } - - public bool TriggerChildAgentUpdate(ulong regionHandle, ChildAgentDataUpdate cAgentData) - { - //m_log.Info("[INTER]: Incoming HGrid Child Agent Data Update"); - - return m_localBackend.TriggerChildAgentUpdate(regionHandle, cAgentData); - } - - /// - /// - /// - /// - /// - /// - public bool IncomingPrim(ulong regionHandle, UUID primID, string objData, int XMLMethod) - { - m_log.Debug("[HGrid]: Incoming Prim"); - m_localBackend.TriggerExpectPrim(regionHandle, primID, objData, XMLMethod); - - return true; - } - - /// - /// - /// - /// - /// - /// - /// - public bool TriggerExpectAvatarCrossing(ulong regionHandle, UUID agentID, Vector3 position, bool isFlying) - { - return m_localBackend.TriggerExpectAvatarCrossing(regionHandle, agentID, position, isFlying); - } - - public bool TriggerExpectPrimCrossing(ulong regionHandle, UUID agentID, Vector3 position, bool isPhysical) - { - return m_localBackend.TriggerExpectPrimCrossing(regionHandle, agentID, position, isPhysical); - } - - public bool TriggerTellRegionToCloseChildConnection(ulong regionHandle, UUID agentID) - { - return m_localBackend.TriggerTellRegionToCloseChildConnection(regionHandle, agentID); - } - - int timeOut = 10; //10 seconds - /// - /// Check that a region is available for TCP comms. This is necessary for .NET remoting between regions. - /// - /// - /// - /// - /// - public bool CheckRegion(string address, uint port, bool retry) - { - bool available = false; - bool timed_out = true; - - IPAddress ia; - IPAddress.TryParse(address, out ia); - IPEndPoint m_EndPoint = new IPEndPoint(ia, (int)port); - - AsyncCallback callback = delegate(IAsyncResult iar) - { - Socket s = (Socket)iar.AsyncState; - try - { - s.EndConnect(iar); - available = true; - timed_out = false; - } - catch (Exception e) - { - m_log.DebugFormat( - "[HGrid]: Callback EndConnect exception: {0}:{1}", e.Message, e.StackTrace); - } - - s.Close(); - }; - - try - { - Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); - IAsyncResult ar = socket.BeginConnect(m_EndPoint, callback, socket); - ar.AsyncWaitHandle.WaitOne(timeOut * 1000, false); - } - catch (Exception e) - { - m_log.DebugFormat( - "[HGrid]: CheckRegion Socket Setup exception: {0}:{1}", e.Message, e.StackTrace); - - return false; - } - - if (timed_out) - { - m_log.DebugFormat( - "[HGrid]: socket [{0}] timed out ({1}) waiting to obtain a connection.", - m_EndPoint, timeOut * 1000); - - if (retry) - { - return CheckRegion(address, port, false); - } - } - - return available; - } - - public override bool CheckRegion(string address, uint port) - { - return CheckRegion(address, port, true); - } - - public void NoteDeadRegion(ulong regionhandle) - { - lock (m_deadRegionCache) - { - if (m_deadRegionCache.ContainsKey(regionhandle)) - { - m_deadRegionCache[regionhandle] = m_deadRegionCache[regionhandle] + 1; - } - else - { - m_deadRegionCache.Add(regionhandle, 1); - } - } - - } - - #endregion - - } } -- cgit v1.1