diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 68b7cdfed2..991acf23ee 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -56,19 +56,21 @@ namespace OpenSim.Services.GridService 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 // 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}.", regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID); 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 RegionData rdata = RegionInfo2RegionData(regionInfos); diff --git a/OpenSim/Services/Interfaces/IGridService.cs b/OpenSim/Services/Interfaces/IGridService.cs index 513b1b01e8..ce432ab8cd 100644 --- a/OpenSim/Services/Interfaces/IGridService.cs +++ b/OpenSim/Services/Interfaces/IGridService.cs @@ -267,6 +267,7 @@ namespace OpenSim.Services.Interfaces kvp["serverIP"] = ExternalHostName; //ExternalEndPoint.Address.ToString(); kvp["serverHttpPort"] = HttpPort.ToString(); kvp["serverURI"] = ServerURI; + kvp["serverPort"] = InternalEndPoint.Port.ToString(); return kvp; } @@ -287,7 +288,7 @@ namespace OpenSim.Services.Interfaces if (kvp.ContainsKey("serverIP")) { - int port = 0; + //int port = 0; //Int32.TryParse((string)kvp["serverPort"], out port); //IPEndPoint ep = new IPEndPoint(IPAddress.Parse((string)kvp["serverIP"]), port); ExternalHostName = (string)kvp["serverIP"]; @@ -295,6 +296,13 @@ namespace OpenSim.Services.Interfaces else 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")) { UInt32 port = 0; diff --git a/OpenSim/Tests/Clients/Grid/GridClient.cs b/OpenSim/Tests/Clients/Grid/GridClient.cs index c56ebc3ca4..941406e693 100644 --- a/OpenSim/Tests/Clients/Grid/GridClient.cs +++ b/OpenSim/Tests/Clients/Grid/GridClient.cs @@ -137,6 +137,9 @@ namespace OpenSim.Tests.Clients.GridClient else Console.WriteLine("[GRID CLIENT]: GetRegionRange returned " + regions.Count + " regions"); + Console.Write("Proceed to deregister? Press enter..."); + Console.ReadLine(); + // Deregister them all Console.WriteLine("[GRID CLIENT]: *** Deregistering region 1"); success = m_Connector.DeregisterRegion(r1.RegionID); @@ -166,7 +169,7 @@ namespace OpenSim.Tests.Clients.GridClient region.RegionID = UUID.Random(); region.ExternalHostName = "127.0.0.1"; 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; }