Fix possible race condition with local region cache if a region was added after startup.
parent
7ca42d5711
commit
5d93c99e8c
|
@ -142,20 +142,26 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
|
|||
|
||||
scene.RegisterModuleInterface<IGridService>(this);
|
||||
|
||||
lock (m_LocalCache)
|
||||
{
|
||||
if (m_LocalCache.ContainsKey(scene.RegionInfo.RegionID))
|
||||
m_log.ErrorFormat("[LOCAL GRID SERVICE CONNECTOR]: simulator seems to have more than one region with the same UUID. Please correct this!");
|
||||
else
|
||||
m_LocalCache.Add(scene.RegionInfo.RegionID, new RegionCache(scene));
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveRegion(Scene scene)
|
||||
{
|
||||
if (!m_Enabled)
|
||||
return;
|
||||
|
||||
lock (m_LocalCache)
|
||||
{
|
||||
m_LocalCache[scene.RegionInfo.RegionID].Clear();
|
||||
m_LocalCache.Remove(scene.RegionInfo.RegionID);
|
||||
}
|
||||
}
|
||||
|
||||
public void RegionLoaded(Scene scene)
|
||||
{
|
||||
|
@ -191,6 +197,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
|
|||
|
||||
// First see if it's a neighbour, even if it isn't on this sim.
|
||||
// Neighbour data is cached in memory, so this is fast
|
||||
|
||||
lock (m_LocalCache)
|
||||
{
|
||||
foreach (RegionCache rcache in m_LocalCache.Values)
|
||||
{
|
||||
region = rcache.GetRegionByPosition(x, y);
|
||||
|
@ -199,6 +208,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
|
|||
return region;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Then try on this sim (may be a lookup in DB if this is using MySql).
|
||||
return m_GridService.GetRegionByPosition(scopeID, x, y);
|
||||
|
@ -245,6 +255,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
|
|||
{
|
||||
System.Text.StringBuilder caps = new System.Text.StringBuilder();
|
||||
|
||||
lock (m_LocalCache)
|
||||
{
|
||||
foreach (KeyValuePair<UUID, RegionCache> kvp in m_LocalCache)
|
||||
{
|
||||
caps.AppendFormat("*** Neighbours of {0} ({1}) ***\n", kvp.Value.RegionName, kvp.Key);
|
||||
|
@ -252,6 +264,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
|
|||
foreach (GridRegion r in regions)
|
||||
caps.AppendFormat(" {0} @ {1}-{2}\n", r.RegionName, r.RegionLocX / Constants.RegionSize, r.RegionLocY / Constants.RegionSize);
|
||||
}
|
||||
}
|
||||
|
||||
MainConsole.Instance.Output(caps.ToString());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue