* If two regions have configuration information that conflicts (save xy location, same uuid or same internal ip port) then complain loudly and don't start up

0.6.0-stable
Justin Clarke Casey 2008-08-18 21:46:07 +00:00
parent 9e6b38078a
commit a179089d1c
2 changed files with 56 additions and 2 deletions

View File

@ -25,6 +25,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
using System.Collections.Generic;
using System.Reflection; using System.Reflection;
using System.Threading; using System.Threading;
using log4net; using log4net;
@ -75,6 +76,12 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
openSim.ModuleLoader.LoadDefaultSharedModules(); openSim.ModuleLoader.LoadDefaultSharedModules();
if (!CheckRegionsForSanity(regionsToLoad))
{
m_log.Error("[LOADREGIONS]: Halting startup due to conflicts in region configurations");
System.Environment.Exit(1);
}
for (int i = 0; i < regionsToLoad.Length; i++) for (int i = 0; i < regionsToLoad.Length; i++)
{ {
m_log.Debug("[LOADREGIONS]: Creating Region: " + regionsToLoad[i].RegionName + " (ThreadID: " + Thread.CurrentThread.ManagedThreadId.ToString() + m_log.Debug("[LOADREGIONS]: Creating Region: " + regionsToLoad[i].RegionName + " (ThreadID: " + Thread.CurrentThread.ManagedThreadId.ToString() +
@ -92,6 +99,52 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
#endregion #endregion
/// <summary>
/// Check that region configuration information makes sense.
/// </summary>
/// <param name="regions"></param>
/// <returns>True if we're sane, false if we're insane</returns>
private bool CheckRegionsForSanity(RegionInfo[] regions)
{
if (regions.Length <= 0)
return true;
List<RegionInfo> checkedRegions = new List<RegionInfo>();
checkedRegions.Add(regions[0]);
for (int i = 1; i < regions.Length; i++)
{
RegionInfo region = regions[i];
foreach (RegionInfo checkedRegion in checkedRegions)
{
if (region.RegionID == checkedRegion.RegionID)
{
m_log.ErrorFormat(
"[LOADREGIONS]: Regions {0} and {1} have the same UUID {2}",
region.RegionName, checkedRegion.RegionName, region.RegionID);
return false;
}
else if (region.RegionLocX == checkedRegion.RegionLocX && region.RegionLocY == checkedRegion.RegionLocY)
{
m_log.ErrorFormat(
"[LOADREGIONS]: Regions {0} and {1} have the same location {2} {3}",
region.RegionName, checkedRegion.RegionName, region.RegionLocX, region.RegionLocY);
return false;
}
else if (region.InternalEndPoint.Port == checkedRegion.InternalEndPoint.Port)
{
m_log.ErrorFormat(
"[LOADREGIONS]: Regions {0} and {1} have the same internal IP port {2}",
region.RegionName, checkedRegion.RegionName, region.InternalEndPoint.Port);
return false;
}
}
}
return true;
}
public void LoadRegionFromConfig(OpenSimBase openSim, ulong regionhandle) public void LoadRegionFromConfig(OpenSimBase openSim, ulong regionhandle)
{ {
m_log.Info("[LOADREGIONS]: Load Regions addin being initialised"); m_log.Info("[LOADREGIONS]: Load Regions addin being initialised");

View File

@ -409,6 +409,7 @@ namespace OpenSim.Data.MySQL
Lfli.Add(fli); Lfli.Add(fli);
} }
reader.Dispose(); reader.Dispose();
result.Dispose(); result.Dispose();
} }