aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/HypergridService
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Services/HypergridService')
-rw-r--r--OpenSim/Services/HypergridService/GatekeeperService.cs30
1 files changed, 27 insertions, 3 deletions
diff --git a/OpenSim/Services/HypergridService/GatekeeperService.cs b/OpenSim/Services/HypergridService/GatekeeperService.cs
index e10c4cb..00502b1 100644
--- a/OpenSim/Services/HypergridService/GatekeeperService.cs
+++ b/OpenSim/Services/HypergridService/GatekeeperService.cs
@@ -72,11 +72,14 @@ namespace OpenSim.Services.HypergridService
72 private static Uri m_Uri; 72 private static Uri m_Uri;
73 private static GridRegion m_DefaultGatewayRegion; 73 private static GridRegion m_DefaultGatewayRegion;
74 74
75 private static Random m_Random;
76
75 public GatekeeperService(IConfigSource config, ISimulationService simService) 77 public GatekeeperService(IConfigSource config, ISimulationService simService)
76 { 78 {
77 if (!m_Initialized) 79 if (!m_Initialized)
78 { 80 {
79 m_Initialized = true; 81 m_Initialized = true;
82 m_Random = new Random();
80 83
81 IConfig serverConfig = config.Configs["GatekeeperService"]; 84 IConfig serverConfig = config.Configs["GatekeeperService"];
82 if (serverConfig == null) 85 if (serverConfig == null)
@@ -220,6 +223,8 @@ namespace OpenSim.Services.HypergridService
220 public bool LoginAgent(AgentCircuitData aCircuit, GridRegion destination, out string reason) 223 public bool LoginAgent(AgentCircuitData aCircuit, GridRegion destination, out string reason)
221 { 224 {
222 reason = string.Empty; 225 reason = string.Empty;
226 List<GridRegion> defaultRegions;
227 List<GridRegion> fallbackRegions;
223 228
224 string authURL = string.Empty; 229 string authURL = string.Empty;
225 if (aCircuit.ServiceURLs.ContainsKey("HomeURI")) 230 if (aCircuit.ServiceURLs.ContainsKey("HomeURI"))
@@ -374,8 +379,14 @@ namespace OpenSim.Services.HypergridService
374 destination = m_GridService.GetRegionByUUID(m_ScopeID, destination.RegionID); 379 destination = m_GridService.GetRegionByUUID(m_ScopeID, destination.RegionID);
375 if (destination == null) 380 if (destination == null)
376 { 381 {
377 reason = "Destination region not found"; 382 defaultRegions = m_GridService.GetDefaultRegions(UUID.Zero);
378 return false; 383 if (defaultRegions == null || (defaultRegions != null && defaultRegions.Count == 0))
384 {
385 reason = "Destination region not found";
386 return false;
387 }
388 int index = m_Random.Next(0, defaultRegions.Count - 1);
389 destination = defaultRegions[index];
379 } 390 }
380 391
381 m_log.DebugFormat( 392 m_log.DebugFormat(
@@ -415,7 +426,20 @@ namespace OpenSim.Services.HypergridService
415 426
416 m_log.DebugFormat("[GATEKEEPER SERVICE]: Launching {0} {1}", aCircuit.Name, loginFlag); 427 m_log.DebugFormat("[GATEKEEPER SERVICE]: Launching {0} {1}", aCircuit.Name, loginFlag);
417 428
418 return m_SimulationService.CreateAgent(destination, aCircuit, (uint)loginFlag, out reason); 429 // try login to the desired region
430 if (m_SimulationService.CreateAgent(destination, aCircuit, (uint)loginFlag, out reason))
431 return true;
432
433 // if that failed, try the fallbacks
434 m_log.DebugFormat("[GATEKEEPER SERVICE]: Region {0} did not accept agent {1}", destination.RegionName, aCircuit.Name);
435 fallbackRegions = m_GridService.GetFallbackRegions(UUID.Zero, destination.RegionLocX, destination.RegionLocY);
436 foreach (GridRegion r in fallbackRegions)
437 {
438 m_log.DebugFormat("[GATEKEEPER SERVICE]: Trying region {0}...", r.RegionName);
439 if (m_SimulationService.CreateAgent(r, aCircuit, (uint)loginFlag, out reason))
440 return true;
441 }
442 return false;
419 } 443 }
420 444
421 protected bool Authenticate(AgentCircuitData aCircuit) 445 protected bool Authenticate(AgentCircuitData aCircuit)