From 7467a471ca2d3e6066f89d8bca4ba956e07fbb6b Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 11 Jan 2010 22:52:05 +0000 Subject: Add the option to reject duplicate region names --- OpenSim/Services/GridService/GridService.cs | 25 +++++++++++++++++++++++++ bin/OpenSim.Server.ini.example | 1 + 2 files changed, 26 insertions(+) diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 86815e5..a500593 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -46,10 +46,18 @@ namespace OpenSim.Services.GridService LogManager.GetLogger( MethodBase.GetCurrentMethod().DeclaringType); + protected bool m_AllowDuplicateNames = false; + public GridService(IConfigSource config) : base(config) { m_log.DebugFormat("[GRID SERVICE]: Starting..."); + + IConfig gridConfig = config.Configs["GridService"]; + if (gridConfig != null) + { + m_AllowDuplicateNames = gridConfig.GetBoolean("AllowDuplicateNames", m_AllowDuplicateNames); + } } #region IGridService @@ -82,6 +90,23 @@ namespace OpenSim.Services.GridService } } + if (!m_AllowDuplicateNames) + { + List dupe = m_Database.Get(regionInfos.RegionName, scopeID); + if (dupe != null && dupe.Count > 0) + { + foreach (RegionData d in dupe) + { + if (d.RegionID != regionInfos.RegionID) + { + m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register duplicate name with ID {1}.", + regionInfos.RegionName, regionInfos.RegionID); + return false; + } + } + } + } + // Everything is ok, let's register RegionData rdata = RegionInfo2RegionData(regionInfos); rdata.ScopeID = scopeID; diff --git a/bin/OpenSim.Server.ini.example b/bin/OpenSim.Server.ini.example index 12af0cd..d4e05af 100644 --- a/bin/OpenSim.Server.ini.example +++ b/bin/OpenSim.Server.ini.example @@ -80,3 +80,4 @@ LocalServiceModule = "OpenSim.Services.GridService.dll:GridService" StorageProvider = "OpenSim.Data.MySQL.dll:MySqlRegionData" ConnectionString = "Data Source=localhost;Database=opensim;User ID=opensim;Password=grid;" Realm = "regions" +; AllowDuplicateNames = "True" -- cgit v1.1