Improve locking in AgentCircuitManager
parent
c934901a05
commit
ced820bd5e
|
@ -38,6 +38,9 @@ namespace OpenSim.Framework
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Agent circuits indexed by circuit code.
|
/// Agent circuits indexed by circuit code.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// We lock this for operations both on this dictionary and on m_agentCircuitsByUUID
|
||||||
|
/// </remarks>
|
||||||
private Dictionary<uint, AgentCircuitData> m_agentCircuits = new Dictionary<uint, AgentCircuitData>();
|
private Dictionary<uint, AgentCircuitData> m_agentCircuits = new Dictionary<uint, AgentCircuitData>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -48,16 +51,20 @@ namespace OpenSim.Framework
|
||||||
public virtual AuthenticateResponse AuthenticateSession(UUID sessionID, UUID agentID, uint circuitcode)
|
public virtual AuthenticateResponse AuthenticateSession(UUID sessionID, UUID agentID, uint circuitcode)
|
||||||
{
|
{
|
||||||
AgentCircuitData validcircuit = null;
|
AgentCircuitData validcircuit = null;
|
||||||
if (m_agentCircuits.ContainsKey(circuitcode))
|
|
||||||
|
lock (m_agentCircuits)
|
||||||
{
|
{
|
||||||
|
if (m_agentCircuits.ContainsKey(circuitcode))
|
||||||
validcircuit = m_agentCircuits[circuitcode];
|
validcircuit = m_agentCircuits[circuitcode];
|
||||||
}
|
}
|
||||||
|
|
||||||
AuthenticateResponse user = new AuthenticateResponse();
|
AuthenticateResponse user = new AuthenticateResponse();
|
||||||
|
|
||||||
if (validcircuit == null)
|
if (validcircuit == null)
|
||||||
{
|
{
|
||||||
//don't have this circuit code in our list
|
//don't have this circuit code in our list
|
||||||
user.Authorised = false;
|
user.Authorised = false;
|
||||||
return (user);
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((sessionID == validcircuit.SessionID) && (agentID == validcircuit.AgentID))
|
if ((sessionID == validcircuit.SessionID) && (agentID == validcircuit.AgentID))
|
||||||
|
@ -79,7 +86,7 @@ namespace OpenSim.Framework
|
||||||
user.Authorised = false;
|
user.Authorised = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (user);
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -129,17 +136,24 @@ namespace OpenSim.Framework
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public AgentCircuitData GetAgentCircuitData(uint circuitCode)
|
public AgentCircuitData GetAgentCircuitData(uint circuitCode)
|
||||||
{
|
{
|
||||||
AgentCircuitData agentCircuit = null;
|
AgentCircuitData agentCircuit = null;
|
||||||
|
|
||||||
|
lock (m_agentCircuits)
|
||||||
m_agentCircuits.TryGetValue(circuitCode, out agentCircuit);
|
m_agentCircuits.TryGetValue(circuitCode, out agentCircuit);
|
||||||
|
|
||||||
return agentCircuit;
|
return agentCircuit;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AgentCircuitData GetAgentCircuitData(UUID agentID)
|
public AgentCircuitData GetAgentCircuitData(UUID agentID)
|
||||||
{
|
{
|
||||||
AgentCircuitData agentCircuit = null;
|
AgentCircuitData agentCircuit = null;
|
||||||
|
|
||||||
|
lock (m_agentCircuits)
|
||||||
m_agentCircuitsByUUID.TryGetValue(agentID, out agentCircuit);
|
m_agentCircuitsByUUID.TryGetValue(agentID, out agentCircuit);
|
||||||
|
|
||||||
return agentCircuit;
|
return agentCircuit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,11 +163,13 @@ namespace OpenSim.Framework
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public Dictionary<UUID, AgentCircuitData> GetAgentCircuits()
|
public Dictionary<UUID, AgentCircuitData> GetAgentCircuits()
|
||||||
{
|
{
|
||||||
lock (m_agentCircuitsByUUID)
|
lock (m_agentCircuits)
|
||||||
return new Dictionary<UUID, AgentCircuitData>(m_agentCircuitsByUUID);
|
return new Dictionary<UUID, AgentCircuitData>(m_agentCircuitsByUUID);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateAgentData(AgentCircuitData agentData)
|
public void UpdateAgentData(AgentCircuitData agentData)
|
||||||
|
{
|
||||||
|
lock (m_agentCircuits)
|
||||||
{
|
{
|
||||||
if (m_agentCircuits.ContainsKey((uint) agentData.circuitcode))
|
if (m_agentCircuits.ContainsKey((uint) agentData.circuitcode))
|
||||||
{
|
{
|
||||||
|
@ -168,6 +184,7 @@ namespace OpenSim.Framework
|
||||||
// m_log.Debug("update user start pos is " + agentData.startpos.X + " , " + agentData.startpos.Y + " , " + agentData.startpos.Z);
|
// m_log.Debug("update user start pos is " + agentData.startpos.X + " , " + agentData.startpos.Y + " , " + agentData.startpos.Z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sometimes the circuitcode may not be known before setting up the connection
|
/// Sometimes the circuitcode may not be known before setting up the connection
|
||||||
|
@ -189,24 +206,23 @@ namespace OpenSim.Framework
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateAgentChildStatus(uint circuitcode, bool childstatus)
|
public void UpdateAgentChildStatus(uint circuitcode, bool childstatus)
|
||||||
{
|
{
|
||||||
|
lock (m_agentCircuits)
|
||||||
if (m_agentCircuits.ContainsKey(circuitcode))
|
if (m_agentCircuits.ContainsKey(circuitcode))
|
||||||
{
|
|
||||||
m_agentCircuits[circuitcode].child = childstatus;
|
m_agentCircuits[circuitcode].child = childstatus;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public bool GetAgentChildStatus(uint circuitcode)
|
public bool GetAgentChildStatus(uint circuitcode)
|
||||||
{
|
{
|
||||||
|
lock (m_agentCircuits)
|
||||||
if (m_agentCircuits.ContainsKey(circuitcode))
|
if (m_agentCircuits.ContainsKey(circuitcode))
|
||||||
{
|
|
||||||
return m_agentCircuits[circuitcode].child;
|
return m_agentCircuits[circuitcode].child;
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue