some changes to AgentCircuitManager
parent
7ef69edf33
commit
38fc68ac0c
|
@ -26,6 +26,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.Concurrent;
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
|
|
||||||
namespace OpenSim.Framework
|
namespace OpenSim.Framework
|
||||||
|
@ -41,26 +42,18 @@ namespace OpenSim.Framework
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// We lock this for operations both on this dictionary and on m_agentCircuitsByUUID
|
/// We lock this for operations both on this dictionary and on m_agentCircuitsByUUID
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
private Dictionary<uint, AgentCircuitData> m_agentCircuits = new Dictionary<uint, AgentCircuitData>();
|
private ConcurrentDictionary<uint, AgentCircuitData> m_agentCircuits = new ConcurrentDictionary<uint, AgentCircuitData>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Agent circuits indexed by agent UUID.
|
/// Agent circuits indexed by agent UUID.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private Dictionary<UUID, AgentCircuitData> m_agentCircuitsByUUID = new Dictionary<UUID, AgentCircuitData>();
|
private ConcurrentDictionary<UUID, AgentCircuitData> m_agentCircuitsByUUID = new ConcurrentDictionary<UUID, AgentCircuitData>();
|
||||||
|
|
||||||
public virtual AuthenticateResponse AuthenticateSession(UUID sessionID, UUID agentID, uint circuitcode)
|
public virtual AuthenticateResponse AuthenticateSession(UUID sessionID, UUID agentID, uint circuitcode)
|
||||||
{
|
{
|
||||||
AgentCircuitData validcircuit = null;
|
|
||||||
|
|
||||||
lock (m_agentCircuits)
|
|
||||||
{
|
|
||||||
if (m_agentCircuits.ContainsKey(circuitcode))
|
|
||||||
validcircuit = m_agentCircuits[circuitcode];
|
|
||||||
}
|
|
||||||
|
|
||||||
AuthenticateResponse user = new AuthenticateResponse();
|
AuthenticateResponse user = new AuthenticateResponse();
|
||||||
|
if (!m_agentCircuits.TryGetValue(circuitcode, out AgentCircuitData validcircuit) || 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;
|
||||||
|
@ -86,7 +79,6 @@ namespace OpenSim.Framework
|
||||||
// Invalid
|
// Invalid
|
||||||
user.Authorised = false;
|
user.Authorised = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,66 +88,39 @@ namespace OpenSim.Framework
|
||||||
/// <param name="circuitCode"></param>
|
/// <param name="circuitCode"></param>
|
||||||
/// <param name="agentData"></param>
|
/// <param name="agentData"></param>
|
||||||
public virtual void AddNewCircuit(uint circuitCode, AgentCircuitData agentData)
|
public virtual void AddNewCircuit(uint circuitCode, AgentCircuitData agentData)
|
||||||
{
|
|
||||||
lock (m_agentCircuits)
|
|
||||||
{
|
|
||||||
if (m_agentCircuits.ContainsKey(circuitCode))
|
|
||||||
{
|
{
|
||||||
m_agentCircuits[circuitCode] = agentData;
|
m_agentCircuits[circuitCode] = agentData;
|
||||||
m_agentCircuitsByUUID[agentData.AgentID] = agentData;
|
m_agentCircuitsByUUID[agentData.AgentID] = agentData;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
m_agentCircuits.Add(circuitCode, agentData);
|
|
||||||
m_agentCircuitsByUUID[agentData.AgentID] = agentData;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual void RemoveCircuit(uint circuitCode)
|
public virtual void RemoveCircuit(uint circuitCode)
|
||||||
{
|
{
|
||||||
lock (m_agentCircuits)
|
if (m_agentCircuits.TryRemove(circuitCode, out AgentCircuitData ac))
|
||||||
{
|
{
|
||||||
if (m_agentCircuits.ContainsKey(circuitCode))
|
m_agentCircuitsByUUID.TryRemove(ac.AgentID, out AgentCircuitData dummy);
|
||||||
{
|
|
||||||
UUID agentID = m_agentCircuits[circuitCode].AgentID;
|
|
||||||
m_agentCircuits.Remove(circuitCode);
|
|
||||||
m_agentCircuitsByUUID.Remove(agentID);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void RemoveCircuit(UUID agentID)
|
public virtual void RemoveCircuit(UUID agentID)
|
||||||
{
|
{
|
||||||
lock (m_agentCircuits)
|
if (m_agentCircuitsByUUID.TryRemove(agentID, out AgentCircuitData ac))
|
||||||
{
|
{
|
||||||
if (m_agentCircuitsByUUID.ContainsKey(agentID))
|
m_agentCircuits.TryRemove(ac.circuitcode, out AgentCircuitData dummy);
|
||||||
{
|
|
||||||
uint circuitCode = m_agentCircuitsByUUID[agentID].circuitcode;
|
|
||||||
m_agentCircuits.Remove(circuitCode);
|
|
||||||
m_agentCircuitsByUUID.Remove(agentID);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public AgentCircuitData GetAgentCircuitData(uint circuitCode)
|
public AgentCircuitData GetAgentCircuitData(uint circuitCode)
|
||||||
{
|
{
|
||||||
AgentCircuitData agentCircuit = null;
|
if(m_agentCircuits.TryGetValue(circuitCode, out AgentCircuitData agentCircuit))
|
||||||
|
|
||||||
lock (m_agentCircuits)
|
|
||||||
m_agentCircuits.TryGetValue(circuitCode, out agentCircuit);
|
|
||||||
|
|
||||||
return agentCircuit;
|
return agentCircuit;
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AgentCircuitData GetAgentCircuitData(UUID agentID)
|
public AgentCircuitData GetAgentCircuitData(UUID agentID)
|
||||||
{
|
{
|
||||||
AgentCircuitData agentCircuit = null;
|
if(m_agentCircuitsByUUID.TryGetValue(agentID, out AgentCircuitData agentCircuit))
|
||||||
|
|
||||||
lock (m_agentCircuits)
|
|
||||||
m_agentCircuitsByUUID.TryGetValue(agentID, out agentCircuit);
|
|
||||||
|
|
||||||
return agentCircuit;
|
return agentCircuit;
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -170,21 +135,16 @@ namespace OpenSim.Framework
|
||||||
|
|
||||||
public void UpdateAgentData(AgentCircuitData agentData)
|
public void UpdateAgentData(AgentCircuitData agentData)
|
||||||
{
|
{
|
||||||
lock (m_agentCircuits)
|
if (m_agentCircuits.TryGetValue(agentData.circuitcode, out AgentCircuitData ac))
|
||||||
{
|
{
|
||||||
if (m_agentCircuits.ContainsKey((uint) agentData.circuitcode))
|
ac.firstname = agentData.firstname;
|
||||||
{
|
ac.lastname = agentData.lastname;
|
||||||
m_agentCircuits[(uint) agentData.circuitcode].firstname = agentData.firstname;
|
ac.startpos = agentData.startpos;
|
||||||
m_agentCircuits[(uint) agentData.circuitcode].lastname = agentData.lastname;
|
ac.startfar = agentData.startfar;
|
||||||
m_agentCircuits[(uint)agentData.circuitcode].startpos = agentData.startpos;
|
|
||||||
m_agentCircuits[(uint)agentData.circuitcode].startfar = agentData.startfar;
|
|
||||||
|
|
||||||
// Updated for when we don't know them before calling Scene.NewUserConnection
|
// Updated for when we don't know them before calling Scene.NewUserConnection
|
||||||
m_agentCircuits[(uint) agentData.circuitcode].SecureSessionID = agentData.SecureSessionID;
|
ac.SecureSessionID = agentData.SecureSessionID;
|
||||||
m_agentCircuits[(uint) agentData.circuitcode].SessionID = agentData.SessionID;
|
ac.SessionID = agentData.SessionID;
|
||||||
|
|
||||||
// m_log.Debug("update user start pos is " + agentData.startpos.X + " , " + agentData.startpos.Y + " , " + agentData.startpos.Z);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,38 +153,30 @@ namespace OpenSim.Framework
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="circuitcode"></param>
|
/// <param name="circuitcode"></param>
|
||||||
/// <param name="newcircuitcode"></param>
|
/// <param name="newcircuitcode"></param>
|
||||||
public bool TryChangeCiruitCode(uint circuitcode, uint newcircuitcode)
|
public bool TryChangeCircuitCode(uint circuitcode, uint newcircuitcode)
|
||||||
{
|
{
|
||||||
lock (m_agentCircuits)
|
if(m_agentCircuits.ContainsKey(newcircuitcode))
|
||||||
|
return false;
|
||||||
|
if (m_agentCircuits.TryRemove(circuitcode, out AgentCircuitData agentData))
|
||||||
{
|
{
|
||||||
if (m_agentCircuits.ContainsKey((uint)circuitcode) && !m_agentCircuits.ContainsKey((uint)newcircuitcode))
|
|
||||||
{
|
|
||||||
AgentCircuitData agentData = m_agentCircuits[(uint)circuitcode];
|
|
||||||
|
|
||||||
agentData.circuitcode = newcircuitcode;
|
agentData.circuitcode = newcircuitcode;
|
||||||
|
m_agentCircuits.TryAdd(newcircuitcode, agentData);
|
||||||
m_agentCircuits.Remove((uint)circuitcode);
|
m_agentCircuitsByUUID[agentData.AgentID] = agentData;
|
||||||
m_agentCircuits.Add(newcircuitcode, agentData);
|
|
||||||
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.TryGetValue(circuitcode, out AgentCircuitData ac))
|
||||||
if (m_agentCircuits.ContainsKey(circuitcode))
|
ac.child = childstatus;
|
||||||
m_agentCircuits[circuitcode].child = childstatus;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool GetAgentChildStatus(uint circuitcode)
|
public bool GetAgentChildStatus(uint circuitcode)
|
||||||
{
|
{
|
||||||
lock (m_agentCircuits)
|
if (m_agentCircuits.TryGetValue(circuitcode, out AgentCircuitData ac))
|
||||||
if (m_agentCircuits.ContainsKey(circuitcode))
|
return ac.child;
|
||||||
return m_agentCircuits[circuitcode].child;
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -150,7 +150,7 @@ namespace OpenSim.Framework.Tests
|
||||||
agentCircuitManager.AddNewCircuit(circuitcode2, m_agentCircuitData2);
|
agentCircuitManager.AddNewCircuit(circuitcode2, m_agentCircuitData2);
|
||||||
bool result = false;
|
bool result = false;
|
||||||
|
|
||||||
result = agentCircuitManager.TryChangeCiruitCode(circuitcode1, 393930);
|
result = agentCircuitManager.TryChangeCircuitCode(circuitcode1, 393930);
|
||||||
|
|
||||||
AgentCircuitData agent = agentCircuitManager.GetAgentCircuitData(393930);
|
AgentCircuitData agent = agentCircuitManager.GetAgentCircuitData(393930);
|
||||||
AgentCircuitData agent2 = agentCircuitManager.GetAgentCircuitData(circuitcode1);
|
AgentCircuitData agent2 = agentCircuitManager.GetAgentCircuitData(circuitcode1);
|
||||||
|
|
|
@ -4463,7 +4463,7 @@ Label_GroupsDone:
|
||||||
/// <returns>True if we successfully changed it. False if we did not</returns>
|
/// <returns>True if we successfully changed it. False if we did not</returns>
|
||||||
public bool ChangeCircuitCode(uint oldcc, uint newcc)
|
public bool ChangeCircuitCode(uint oldcc, uint newcc)
|
||||||
{
|
{
|
||||||
return m_authenticateHandler.TryChangeCiruitCode(oldcc, newcc);
|
return m_authenticateHandler.TryChangeCircuitCode(oldcc, newcc);
|
||||||
}
|
}
|
||||||
|
|
||||||
// /// <summary>
|
// /// <summary>
|
||||||
|
|
Loading…
Reference in New Issue