Add the option to reject duplicate region names
parent
07aaad0d10
commit
7467a471ca
|
@ -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<RegionData> 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;
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue