Better guards on RegisterRegion in GridService.

Added serverPort to the fields that get stored (I think this is the UDP port).
remotes/origin/0.6.7-post-fixes
Diva Canto 2009-09-25 06:02:41 -07:00
parent eb0aa6a7f4
commit 52e477b41f
3 changed files with 21 additions and 8 deletions

View File

@ -56,19 +56,21 @@ namespace OpenSim.Services.GridService
public bool RegisterRegion(UUID scopeID, GridRegion regionInfos) public bool RegisterRegion(UUID scopeID, GridRegion regionInfos)
{ {
if (m_Database.Get(regionInfos.RegionID, scopeID) != null)
{
m_log.WarnFormat("[GRID SERVICE]: Region {0} already registered in scope {1}.", regionInfos.RegionID, scopeID);
return false;
}
// This needs better sanity testing. What if regionInfo is registering in // This needs better sanity testing. What if regionInfo is registering in
// overlapping coords? // overlapping coords?
if (m_Database.Get(regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID) != null) RegionData region = m_Database.Get(regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID);
if ((region != null) && (region.RegionID != regionInfos.RegionID))
{ {
m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register in coordinates {1}, {2} which are already in use in scope {3}.", m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register in coordinates {1}, {2} which are already in use in scope {3}.",
regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID); regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID);
return false; return false;
} }
if ((region != null) && (region.RegionID == regionInfos.RegionID) &&
((region.posX != regionInfos.RegionLocX) || (region.posY != regionInfos.RegionLocY)))
{
// Region reregistering in other coordinates. Delete the old entry
m_Database.Delete(regionInfos.RegionID);
}
// Everything is ok, let's register // Everything is ok, let's register
RegionData rdata = RegionInfo2RegionData(regionInfos); RegionData rdata = RegionInfo2RegionData(regionInfos);

View File

@ -267,6 +267,7 @@ namespace OpenSim.Services.Interfaces
kvp["serverIP"] = ExternalHostName; //ExternalEndPoint.Address.ToString(); kvp["serverIP"] = ExternalHostName; //ExternalEndPoint.Address.ToString();
kvp["serverHttpPort"] = HttpPort.ToString(); kvp["serverHttpPort"] = HttpPort.ToString();
kvp["serverURI"] = ServerURI; kvp["serverURI"] = ServerURI;
kvp["serverPort"] = InternalEndPoint.Port.ToString();
return kvp; return kvp;
} }
@ -287,7 +288,7 @@ namespace OpenSim.Services.Interfaces
if (kvp.ContainsKey("serverIP")) if (kvp.ContainsKey("serverIP"))
{ {
int port = 0; //int port = 0;
//Int32.TryParse((string)kvp["serverPort"], out port); //Int32.TryParse((string)kvp["serverPort"], out port);
//IPEndPoint ep = new IPEndPoint(IPAddress.Parse((string)kvp["serverIP"]), port); //IPEndPoint ep = new IPEndPoint(IPAddress.Parse((string)kvp["serverIP"]), port);
ExternalHostName = (string)kvp["serverIP"]; ExternalHostName = (string)kvp["serverIP"];
@ -295,6 +296,13 @@ namespace OpenSim.Services.Interfaces
else else
ExternalHostName = "127.0.0.1"; ExternalHostName = "127.0.0.1";
if (kvp.ContainsKey("serverPort"))
{
Int32 port = 0;
Int32.TryParse((string)kvp["serverPort"], out port);
InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), port);
}
if (kvp.ContainsKey("serverHttpPort")) if (kvp.ContainsKey("serverHttpPort"))
{ {
UInt32 port = 0; UInt32 port = 0;

View File

@ -137,6 +137,9 @@ namespace OpenSim.Tests.Clients.GridClient
else else
Console.WriteLine("[GRID CLIENT]: GetRegionRange returned " + regions.Count + " regions"); Console.WriteLine("[GRID CLIENT]: GetRegionRange returned " + regions.Count + " regions");
Console.Write("Proceed to deregister? Press enter...");
Console.ReadLine();
// Deregister them all // Deregister them all
Console.WriteLine("[GRID CLIENT]: *** Deregistering region 1"); Console.WriteLine("[GRID CLIENT]: *** Deregistering region 1");
success = m_Connector.DeregisterRegion(r1.RegionID); success = m_Connector.DeregisterRegion(r1.RegionID);
@ -166,7 +169,7 @@ namespace OpenSim.Tests.Clients.GridClient
region.RegionID = UUID.Random(); region.RegionID = UUID.Random();
region.ExternalHostName = "127.0.0.1"; region.ExternalHostName = "127.0.0.1";
region.HttpPort = 9000; region.HttpPort = 9000;
region.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 0); region.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 9000);
return region; return region;
} }