From 98f29a47c0ad63fa20d4e3fa64971d0d0a5e959c Mon Sep 17 00:00:00 2001 From: Marck Date: Tue, 2 Nov 2010 20:00:14 +0100 Subject: [PATCH] Do not include hyperlinks in a random region search during a login. Before a random region is chosen, available fallback regions are used for the login. --- .../Services/LLLoginService/LLLoginService.cs | 40 ++++++++++++++----- prebuild.xml | 1 + 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/OpenSim/Services/LLLoginService/LLLoginService.cs b/OpenSim/Services/LLLoginService/LLLoginService.cs index a06476e9cb..fcfdd1d6d9 100644 --- a/OpenSim/Services/LLLoginService/LLLoginService.cs +++ b/OpenSim/Services/LLLoginService/LLLoginService.cs @@ -28,6 +28,7 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Linq; using System.Net; using System.Reflection; using System.Text.RegularExpressions; @@ -427,12 +428,9 @@ namespace OpenSim.Services.LLLoginService { m_log.WarnFormat("[LLOGIN SERVICE]: User {0} {1} does not have a valid home and this grid does not have default locations. Attempting to find random region", account.FirstName, account.LastName); - defaults = m_GridService.GetRegionsByName(scopeID, "", 1); - if (defaults != null && defaults.Count > 0) - { - region = defaults[0]; + region = FindAlternativeRegion(scopeID); + if (region != null) where = "safe"; - } } } @@ -459,12 +457,9 @@ namespace OpenSim.Services.LLLoginService else { m_log.Info("[LLOGIN SERVICE]: Last Region Not Found Attempting to find random region"); - defaults = m_GridService.GetRegionsByName(scopeID, "", 1); - if (defaults != null && defaults.Count > 0) - { - region = defaults[0]; + region = FindAlternativeRegion(scopeID); + if (region != null) where = "safe"; - } } } @@ -564,6 +559,31 @@ namespace OpenSim.Services.LLLoginService } + private GridRegion FindAlternativeRegion(UUID scopeID) + { + List hyperlinks = null; + List regions = m_GridService.GetFallbackRegions(scopeID, 1000 * (int)Constants.RegionSize, 1000 * (int)Constants.RegionSize); + if (regions != null && regions.Count > 0) + { + hyperlinks = m_GridService.GetHyperlinks(scopeID); + IEnumerable availableRegions = regions.Except(hyperlinks); + if (availableRegions.Count() > 0) + return availableRegions.ElementAt(0); + } + // No fallbacks, try to find an arbitrary region that is not a hyperlink + // maxNumber is fixed for now; maybe use some search pattern with increasing maxSize here? + regions = m_GridService.GetRegionsByName(scopeID, "", 10); + if (regions != null && regions.Count > 0) + { + if (hyperlinks == null) + hyperlinks = m_GridService.GetHyperlinks(scopeID); + IEnumerable availableRegions = regions.Except(hyperlinks); + if (availableRegions.Count() > 0) + return availableRegions.ElementAt(0); + } + return null; + } + private GridRegion FindForeignRegion(string domainName, uint port, string regionName, out GridRegion gatekeeper) { gatekeeper = new GridRegion(); diff --git a/prebuild.xml b/prebuild.xml index e77d5c1fd2..ac003d9a17 100644 --- a/prebuild.xml +++ b/prebuild.xml @@ -1214,6 +1214,7 @@ ../../../bin/ +