Make dictionary read/write locking consistent in CapabilitiesModule, rename two dictionary fields to standard m_ format
parent
2f6ee8aee2
commit
a38c2abae4
|
@ -57,8 +57,8 @@ namespace OpenSim.Region.CoreModules.Framework
|
|||
/// </summary>
|
||||
protected Dictionary<UUID, Caps> m_capsObjects = new Dictionary<UUID, Caps>();
|
||||
|
||||
protected Dictionary<UUID, string> capsPaths = new Dictionary<UUID, string>();
|
||||
protected Dictionary<UUID, Dictionary<ulong, string>> childrenSeeds
|
||||
protected Dictionary<UUID, string> m_capsPaths = new Dictionary<UUID, string>();
|
||||
protected Dictionary<UUID, Dictionary<ulong, string>> m_childrenSeeds
|
||||
= new Dictionary<UUID, Dictionary<ulong, string>>();
|
||||
|
||||
public void Initialise(IConfigSource source)
|
||||
|
@ -105,35 +105,42 @@ namespace OpenSim.Region.CoreModules.Framework
|
|||
if (m_scene.RegionInfo.EstateSettings.IsBanned(agentId))
|
||||
return;
|
||||
|
||||
Caps caps;
|
||||
String capsObjectPath = GetCapsPath(agentId);
|
||||
|
||||
if (m_capsObjects.ContainsKey(agentId))
|
||||
lock (m_capsObjects)
|
||||
{
|
||||
Caps oldCaps = m_capsObjects[agentId];
|
||||
if (m_capsObjects.ContainsKey(agentId))
|
||||
{
|
||||
Caps oldCaps = m_capsObjects[agentId];
|
||||
|
||||
m_log.DebugFormat(
|
||||
"[CAPS]: Recreating caps for agent {0}. Old caps path {1}, new caps path {2}. ",
|
||||
agentId, oldCaps.CapsObjectPath, capsObjectPath);
|
||||
// This should not happen. The caller code is confused. We need to fix that.
|
||||
// CAPs can never be reregistered, or the client will be confused.
|
||||
// Hence this return here.
|
||||
//return;
|
||||
m_log.DebugFormat(
|
||||
"[CAPS]: Recreating caps for agent {0}. Old caps path {1}, new caps path {2}. ",
|
||||
agentId, oldCaps.CapsObjectPath, capsObjectPath);
|
||||
// This should not happen. The caller code is confused. We need to fix that.
|
||||
// CAPs can never be reregistered, or the client will be confused.
|
||||
// Hence this return here.
|
||||
//return;
|
||||
}
|
||||
|
||||
caps = new Caps(MainServer.Instance, m_scene.RegionInfo.ExternalHostName,
|
||||
(MainServer.Instance == null) ? 0: MainServer.Instance.Port,
|
||||
capsObjectPath, agentId, m_scene.RegionInfo.RegionName);
|
||||
|
||||
m_capsObjects[agentId] = caps;
|
||||
}
|
||||
|
||||
Caps caps = new Caps(MainServer.Instance, m_scene.RegionInfo.ExternalHostName,
|
||||
(MainServer.Instance == null) ? 0: MainServer.Instance.Port,
|
||||
capsObjectPath, agentId, m_scene.RegionInfo.RegionName);
|
||||
|
||||
m_capsObjects[agentId] = caps;
|
||||
|
||||
m_scene.EventManager.TriggerOnRegisterCaps(agentId, caps);
|
||||
}
|
||||
|
||||
public void RemoveCaps(UUID agentId)
|
||||
{
|
||||
if (childrenSeeds.ContainsKey(agentId))
|
||||
lock (m_childrenSeeds)
|
||||
{
|
||||
childrenSeeds.Remove(agentId);
|
||||
if (m_childrenSeeds.ContainsKey(agentId))
|
||||
{
|
||||
m_childrenSeeds.Remove(agentId);
|
||||
}
|
||||
}
|
||||
|
||||
lock (m_capsObjects)
|
||||
|
@ -168,16 +175,22 @@ namespace OpenSim.Region.CoreModules.Framework
|
|||
|
||||
public void SetAgentCapsSeeds(AgentCircuitData agent)
|
||||
{
|
||||
capsPaths[agent.AgentID] = agent.CapsPath;
|
||||
childrenSeeds[agent.AgentID]
|
||||
= ((agent.ChildrenCapSeeds == null) ? new Dictionary<ulong, string>() : agent.ChildrenCapSeeds);
|
||||
lock (m_capsPaths)
|
||||
m_capsPaths[agent.AgentID] = agent.CapsPath;
|
||||
|
||||
lock (m_childrenSeeds)
|
||||
m_childrenSeeds[agent.AgentID]
|
||||
= ((agent.ChildrenCapSeeds == null) ? new Dictionary<ulong, string>() : agent.ChildrenCapSeeds);
|
||||
}
|
||||
|
||||
public string GetCapsPath(UUID agentId)
|
||||
{
|
||||
if (capsPaths.ContainsKey(agentId))
|
||||
lock (m_capsPaths)
|
||||
{
|
||||
return capsPaths[agentId];
|
||||
if (m_capsPaths.ContainsKey(agentId))
|
||||
{
|
||||
return m_capsPaths[agentId];
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -186,17 +199,24 @@ namespace OpenSim.Region.CoreModules.Framework
|
|||
public Dictionary<ulong, string> GetChildrenSeeds(UUID agentID)
|
||||
{
|
||||
Dictionary<ulong, string> seeds = null;
|
||||
if (childrenSeeds.TryGetValue(agentID, out seeds))
|
||||
return seeds;
|
||||
|
||||
lock (m_childrenSeeds)
|
||||
if (m_childrenSeeds.TryGetValue(agentID, out seeds))
|
||||
return seeds;
|
||||
|
||||
return new Dictionary<ulong, string>();
|
||||
}
|
||||
|
||||
public void DropChildSeed(UUID agentID, ulong handle)
|
||||
{
|
||||
Dictionary<ulong, string> seeds;
|
||||
if (childrenSeeds.TryGetValue(agentID, out seeds))
|
||||
|
||||
lock (m_childrenSeeds)
|
||||
{
|
||||
seeds.Remove(handle);
|
||||
if (m_childrenSeeds.TryGetValue(agentID, out seeds))
|
||||
{
|
||||
seeds.Remove(handle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -204,30 +224,41 @@ namespace OpenSim.Region.CoreModules.Framework
|
|||
{
|
||||
Dictionary<ulong, string> seeds;
|
||||
string returnval;
|
||||
if (childrenSeeds.TryGetValue(agentID, out seeds))
|
||||
|
||||
lock (m_childrenSeeds)
|
||||
{
|
||||
if (seeds.TryGetValue(handle, out returnval))
|
||||
return returnval;
|
||||
if (m_childrenSeeds.TryGetValue(agentID, out seeds))
|
||||
{
|
||||
if (seeds.TryGetValue(handle, out returnval))
|
||||
return returnval;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void SetChildrenSeed(UUID agentID, Dictionary<ulong, string> seeds)
|
||||
{
|
||||
//m_log.DebugFormat(" !!! Setting child seeds in {0} to {1}", m_scene.RegionInfo.RegionName, seeds.Count);
|
||||
childrenSeeds[agentID] = seeds;
|
||||
|
||||
lock (m_childrenSeeds)
|
||||
m_childrenSeeds[agentID] = seeds;
|
||||
}
|
||||
|
||||
public void DumpChildrenSeeds(UUID agentID)
|
||||
{
|
||||
m_log.Info("================ ChildrenSeed "+m_scene.RegionInfo.RegionName+" ================");
|
||||
foreach (KeyValuePair<ulong, string> kvp in childrenSeeds[agentID])
|
||||
|
||||
lock (m_childrenSeeds)
|
||||
{
|
||||
uint x, y;
|
||||
Utils.LongToUInts(kvp.Key, out x, out y);
|
||||
x = x / Constants.RegionSize;
|
||||
y = y / Constants.RegionSize;
|
||||
m_log.Info(" >> "+x+", "+y+": "+kvp.Value);
|
||||
foreach (KeyValuePair<ulong, string> kvp in m_childrenSeeds[agentID])
|
||||
{
|
||||
uint x, y;
|
||||
Utils.LongToUInts(kvp.Key, out x, out y);
|
||||
x = x / Constants.RegionSize;
|
||||
y = y / Constants.RegionSize;
|
||||
m_log.Info(" >> "+x+", "+y+": "+kvp.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -236,18 +267,21 @@ namespace OpenSim.Region.CoreModules.Framework
|
|||
StringBuilder caps = new StringBuilder();
|
||||
caps.AppendFormat("Region {0}:\n", m_scene.RegionInfo.RegionName);
|
||||
|
||||
foreach (KeyValuePair<UUID, Caps> kvp in m_capsObjects)
|
||||
lock (m_capsObjects)
|
||||
{
|
||||
caps.AppendFormat("** User {0}:\n", kvp.Key);
|
||||
|
||||
for (IDictionaryEnumerator kvp2 = kvp.Value.CapsHandlers.GetCapsDetails(false, null).GetEnumerator(); kvp2.MoveNext(); )
|
||||
foreach (KeyValuePair<UUID, Caps> kvp in m_capsObjects)
|
||||
{
|
||||
Uri uri = new Uri(kvp2.Value.ToString());
|
||||
caps.AppendFormat(m_showCapsCommandFormat, kvp2.Key, uri.PathAndQuery);
|
||||
}
|
||||
caps.AppendFormat("** User {0}:\n", kvp.Key);
|
||||
|
||||
foreach (KeyValuePair<string, string> kvp3 in kvp.Value.ExternalCapsHandlers)
|
||||
caps.AppendFormat(m_showCapsCommandFormat, kvp3.Key, kvp3.Value);
|
||||
for (IDictionaryEnumerator kvp2 = kvp.Value.CapsHandlers.GetCapsDetails(false, null).GetEnumerator(); kvp2.MoveNext(); )
|
||||
{
|
||||
Uri uri = new Uri(kvp2.Value.ToString());
|
||||
caps.AppendFormat(m_showCapsCommandFormat, kvp2.Key, uri.PathAndQuery);
|
||||
}
|
||||
|
||||
foreach (KeyValuePair<string, string> kvp3 in kvp.Value.ExternalCapsHandlers)
|
||||
caps.AppendFormat(m_showCapsCommandFormat, kvp3.Key, kvp3.Value);
|
||||
}
|
||||
}
|
||||
|
||||
MainConsole.Instance.Output(caps.ToString());
|
||||
|
|
Loading…
Reference in New Issue