Make HG logins fall back to fallback regions if the desired region fails.

varregion
Diva Canto 2013-08-24 03:41:56 -07:00
parent 6a24515269
commit c7a8afbb8d
1 changed files with 24 additions and 3 deletions

View File

@ -72,11 +72,14 @@ namespace OpenSim.Services.HypergridService
private static Uri m_Uri;
private static GridRegion m_DefaultGatewayRegion;
private static Random m_Random;
public GatekeeperService(IConfigSource config, ISimulationService simService)
{
if (!m_Initialized)
{
m_Initialized = true;
m_Random = new Random();
IConfig serverConfig = config.Configs["GatekeeperService"];
if (serverConfig == null)
@ -220,6 +223,8 @@ namespace OpenSim.Services.HypergridService
public bool LoginAgent(AgentCircuitData aCircuit, GridRegion destination, out string reason)
{
reason = string.Empty;
List<GridRegion> defaultRegions;
List<GridRegion> fallbackRegions;
string authURL = string.Empty;
if (aCircuit.ServiceURLs.ContainsKey("HomeURI"))
@ -373,10 +378,16 @@ namespace OpenSim.Services.HypergridService
//
destination = m_GridService.GetRegionByUUID(m_ScopeID, destination.RegionID);
if (destination == null)
{
defaultRegions = m_GridService.GetDefaultRegions(UUID.Zero);
if (defaultRegions == null || (defaultRegions != null && defaultRegions.Count == 0))
{
reason = "Destination region not found";
return false;
}
int index = m_Random.Next(0, defaultRegions.Count - 1);
destination = defaultRegions[index];
}
m_log.DebugFormat(
"[GATEKEEPER SERVICE]: Destination {0} is ok for {1}", destination.RegionName, aCircuit.Name);
@ -415,7 +426,17 @@ namespace OpenSim.Services.HypergridService
m_log.DebugFormat("[GATEKEEPER SERVICE]: Launching {0} {1}", aCircuit.Name, loginFlag);
return m_SimulationService.CreateAgent(destination, aCircuit, (uint)loginFlag, out reason);
// try login to the desired region
if (m_SimulationService.CreateAgent(destination, aCircuit, (uint)loginFlag, out reason))
return true;
// if that failed, try the fallbacks
fallbackRegions = m_GridService.GetFallbackRegions(UUID.Zero, destination.RegionLocX, destination.RegionLocY);
foreach (GridRegion r in fallbackRegions)
if (m_SimulationService.CreateAgent(r, aCircuit, (uint)loginFlag, out reason))
return true;
return false;
}
protected bool Authenticate(AgentCircuitData aCircuit)