From fcf61c4d0db38e39e1db9e54602290ab0f1f1204 Mon Sep 17 00:00:00 2001 From: diva Date: Sat, 20 Dec 2008 18:15:02 +0000 Subject: [PATCH] This reduces DNS lookups in TPs by a factor of 4. Let's see if this fixes some of the crashes experienced by ppl in Europe connected to OSGrid. If DNS lookup does not resolve, they may experience a substantial increase in "Region not available", but they shouldn't crash. --- .../Hypergrid/HGSceneCommunicationService.cs | 21 ++++++++++++---- OpenSim/Region/Environment/Scenes/Scene.cs | 4 ++-- .../Scenes/SceneCommunicationService.cs | 24 ++++++++++++++----- 3 files changed, 36 insertions(+), 13 deletions(-) diff --git a/OpenSim/Region/Environment/Scenes/Hypergrid/HGSceneCommunicationService.cs b/OpenSim/Region/Environment/Scenes/Hypergrid/HGSceneCommunicationService.cs index d4f66c7585..0ee0869c16 100644 --- a/OpenSim/Region/Environment/Scenes/Hypergrid/HGSceneCommunicationService.cs +++ b/OpenSim/Region/Environment/Scenes/Hypergrid/HGSceneCommunicationService.cs @@ -28,6 +28,7 @@ using System; using System.Collections.Generic; +using System.Net; using System.Reflection; using System.Threading; @@ -148,6 +149,16 @@ namespace OpenSim.Region.Environment.Scenes.Hypergrid destRegionUp = true; } + // Let's do DNS resolution only once in this process, please! + // This may be a costly operation. The reg.ExternalEndPoint field is not a passive field, + // it's actually doing a lot of work. + IPEndPoint endPoint = reg.ExternalEndPoint; + if (endPoint.Address == null) + { + // Couldn't resolve the name. Can't TP, because the viewer wants IP addresses. + destRegionUp = false; + } + if (destRegionUp) { @@ -206,15 +217,15 @@ namespace OpenSim.Region.Environment.Scenes.Hypergrid if (eq != null) { - OSD Item = EventQueueHelper.EnableSimulator(realHandle, reg.ExternalEndPoint); + OSD Item = EventQueueHelper.EnableSimulator(realHandle, endPoint); eq.Enqueue(Item, avatar.UUID); - Item = EventQueueHelper.EstablishAgentCommunication(avatar.UUID, reg.ExternalEndPoint.ToString(), capsPath); + Item = EventQueueHelper.EstablishAgentCommunication(avatar.UUID, endPoint.ToString(), capsPath); eq.Enqueue(Item, avatar.UUID); } else { - avatar.ControllingClient.InformClientOfNeighbour(realHandle, reg.ExternalEndPoint); + avatar.ControllingClient.InformClientOfNeighbour(realHandle, endPoint); // TODO: make Event Queue disablable! } } @@ -252,13 +263,13 @@ namespace OpenSim.Region.Environment.Scenes.Hypergrid /// if (eq != null) { - OSD Item = EventQueueHelper.TeleportFinishEvent(realHandle, 13, reg.ExternalEndPoint, + OSD Item = EventQueueHelper.TeleportFinishEvent(realHandle, 13, endPoint, 4, teleportFlags, capsPath, avatar.UUID); eq.Enqueue(Item, avatar.UUID); } else { - avatar.ControllingClient.SendRegionTeleport(realHandle, 13, reg.ExternalEndPoint, 4, + avatar.ControllingClient.SendRegionTeleport(realHandle, 13, endPoint, 4, teleportFlags, capsPath); } /// diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 1476f88ab3..2b8ee7461d 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -2673,7 +2673,7 @@ namespace OpenSim.Region.Environment.Scenes m_sceneGridService.OnRegionUp += OtherRegionUp; m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate; m_sceneGridService.OnExpectPrim += IncomingInterRegionPrimGroup; - m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar; + //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar; m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid; m_sceneGridService.KiPrimitive += SendKillObject; m_sceneGridService.OnGetLandData += GetLandData; @@ -2686,7 +2686,7 @@ namespace OpenSim.Region.Environment.Scenes { m_sceneGridService.KiPrimitive -= SendKillObject; m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid; - m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar; + //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar; m_sceneGridService.OnExpectPrim -= IncomingInterRegionPrimGroup; m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; m_sceneGridService.OnRegionUp -= OtherRegionUp; diff --git a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs index 1d50865ffc..2bfb7d6fa6 100644 --- a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs @@ -60,7 +60,7 @@ namespace OpenSim.Region.Environment.Scenes public event PrimCrossing OnPrimCrossingIntoRegion; public event RegionUp OnRegionUp; public event ChildAgentUpdate OnChildAgentUpdate; - public event RemoveKnownRegionsFromAvatarList OnRemoveKnownRegionFromAvatar; + //public event RemoveKnownRegionsFromAvatarList OnRemoveKnownRegionFromAvatar; public event LogOffUser OnLogOffUser; public event GetLandData OnGetLandData; @@ -729,6 +729,7 @@ namespace OpenSim.Region.Environment.Scenes { // region is remote. see if it is up destRegionUp = m_commsProvider.InterRegion.CheckRegion(reg.RemotingAddress, reg.RemotingPort); + } else { @@ -736,6 +737,16 @@ namespace OpenSim.Region.Environment.Scenes destRegionUp = true; } + // Let's do DNS resolution only once in this process, please! + // This may be a costly operation. The reg.ExternalEndPoint field is not a passive field, + // it's actually doing a lot of work. + IPEndPoint endPoint = reg.ExternalEndPoint; + if (endPoint.Address == null) + { + // Couldn't resolve the name. Can't TP, because the viewer wants IP addresses. + destRegionUp = false; + } + if (destRegionUp) { uint newRegionX = (uint)(reg.RegionHandle >> 40); @@ -761,6 +772,7 @@ namespace OpenSim.Region.Environment.Scenes // once we reach here... //avatar.Scene.RemoveCapsHandler(avatar.UUID); + // Let's close some agents avatar.CloseChildAgents(newRegionX, newRegionY); @@ -791,15 +803,15 @@ namespace OpenSim.Region.Environment.Scenes if (eq != null) { - OSD Item = EventQueueHelper.EnableSimulator(reg.RegionHandle, reg.ExternalEndPoint); + OSD Item = EventQueueHelper.EnableSimulator(reg.RegionHandle, endPoint); eq.Enqueue(Item, avatar.UUID); - Item = EventQueueHelper.EstablishAgentCommunication(avatar.UUID, reg.ExternalEndPoint.ToString(), capsPath); + Item = EventQueueHelper.EstablishAgentCommunication(avatar.UUID, endPoint.ToString(), capsPath); eq.Enqueue(Item, avatar.UUID); } else { - avatar.ControllingClient.InformClientOfNeighbour(reg.RegionHandle, reg.ExternalEndPoint); + avatar.ControllingClient.InformClientOfNeighbour(reg.RegionHandle, endPoint); } } else @@ -829,13 +841,13 @@ namespace OpenSim.Region.Environment.Scenes if (eq != null) { - OSD Item = EventQueueHelper.TeleportFinishEvent(reg.RegionHandle, 13, reg.ExternalEndPoint, + OSD Item = EventQueueHelper.TeleportFinishEvent(reg.RegionHandle, 13, endPoint, 4, teleportFlags, capsPath, avatar.UUID); eq.Enqueue(Item, avatar.UUID); } else { - avatar.ControllingClient.SendRegionTeleport(reg.RegionHandle, 13, reg.ExternalEndPoint, 4, + avatar.ControllingClient.SendRegionTeleport(reg.RegionHandle, 13, endPoint, 4, teleportFlags, capsPath); }