aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2011-12-03 16:11:47 +0000
committerJustin Clark-Casey (justincc)2011-12-03 16:11:47 +0000
commitc934901a056f142c49e6b449971fcaf59ff19d82 (patch)
treed3376fd8c5ff665dc3045f68250b6b9fe547a53a /OpenSim
parentAdd agent circuit number checks to TestCloseAgent() (diff)
downloadopensim-SC_OLD-c934901a056f142c49e6b449971fcaf59ff19d82.zip
opensim-SC_OLD-c934901a056f142c49e6b449971fcaf59ff19d82.tar.gz
opensim-SC_OLD-c934901a056f142c49e6b449971fcaf59ff19d82.tar.bz2
opensim-SC_OLD-c934901a056f142c49e6b449971fcaf59ff19d82.tar.xz
Use GetAgentCircuits() to receive a copy of the AgentCircuitsByUUID dictionary rather than AgentCircuitManager.AgentCircuits directly in "show circuits" to avoid enumeration exceptions
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Framework/AgentCircuitManager.cs91
-rw-r--r--OpenSim/Region/Application/OpenSim.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs6
3 files changed, 57 insertions, 42 deletions
diff --git a/OpenSim/Framework/AgentCircuitManager.cs b/OpenSim/Framework/AgentCircuitManager.cs
index 1ce8c34..a59bcfa 100644
--- a/OpenSim/Framework/AgentCircuitManager.cs
+++ b/OpenSim/Framework/AgentCircuitManager.cs
@@ -35,15 +35,22 @@ namespace OpenSim.Framework
35 /// </summary> 35 /// </summary>
36 public class AgentCircuitManager 36 public class AgentCircuitManager
37 { 37 {
38 public Dictionary<uint, AgentCircuitData> AgentCircuits = new Dictionary<uint, AgentCircuitData>(); 38 /// <summary>
39 public Dictionary<UUID, AgentCircuitData> AgentCircuitsByUUID = new Dictionary<UUID, AgentCircuitData>(); 39 /// Agent circuits indexed by circuit code.
40 /// </summary>
41 private Dictionary<uint, AgentCircuitData> m_agentCircuits = new Dictionary<uint, AgentCircuitData>();
42
43 /// <summary>
44 /// Agent circuits indexed by agent UUID.
45 /// </summary>
46 private Dictionary<UUID, AgentCircuitData> m_agentCircuitsByUUID = new Dictionary<UUID, AgentCircuitData>();
40 47
41 public virtual AuthenticateResponse AuthenticateSession(UUID sessionID, UUID agentID, uint circuitcode) 48 public virtual AuthenticateResponse AuthenticateSession(UUID sessionID, UUID agentID, uint circuitcode)
42 { 49 {
43 AgentCircuitData validcircuit = null; 50 AgentCircuitData validcircuit = null;
44 if (AgentCircuits.ContainsKey(circuitcode)) 51 if (m_agentCircuits.ContainsKey(circuitcode))
45 { 52 {
46 validcircuit = AgentCircuits[circuitcode]; 53 validcircuit = m_agentCircuits[circuitcode];
47 } 54 }
48 AuthenticateResponse user = new AuthenticateResponse(); 55 AuthenticateResponse user = new AuthenticateResponse();
49 if (validcircuit == null) 56 if (validcircuit == null)
@@ -82,71 +89,81 @@ namespace OpenSim.Framework
82 /// <param name="agentData"></param> 89 /// <param name="agentData"></param>
83 public virtual void AddNewCircuit(uint circuitCode, AgentCircuitData agentData) 90 public virtual void AddNewCircuit(uint circuitCode, AgentCircuitData agentData)
84 { 91 {
85 lock (AgentCircuits) 92 lock (m_agentCircuits)
86 { 93 {
87 if (AgentCircuits.ContainsKey(circuitCode)) 94 if (m_agentCircuits.ContainsKey(circuitCode))
88 { 95 {
89 AgentCircuits[circuitCode] = agentData; 96 m_agentCircuits[circuitCode] = agentData;
90 AgentCircuitsByUUID[agentData.AgentID] = agentData; 97 m_agentCircuitsByUUID[agentData.AgentID] = agentData;
91 } 98 }
92 else 99 else
93 { 100 {
94 AgentCircuits.Add(circuitCode, agentData); 101 m_agentCircuits.Add(circuitCode, agentData);
95 AgentCircuitsByUUID[agentData.AgentID] = agentData; 102 m_agentCircuitsByUUID[agentData.AgentID] = agentData;
96 } 103 }
97 } 104 }
98 } 105 }
99 106
100 public virtual void RemoveCircuit(uint circuitCode) 107 public virtual void RemoveCircuit(uint circuitCode)
101 { 108 {
102 lock (AgentCircuits) 109 lock (m_agentCircuits)
103 { 110 {
104 if (AgentCircuits.ContainsKey(circuitCode)) 111 if (m_agentCircuits.ContainsKey(circuitCode))
105 { 112 {
106 UUID agentID = AgentCircuits[circuitCode].AgentID; 113 UUID agentID = m_agentCircuits[circuitCode].AgentID;
107 AgentCircuits.Remove(circuitCode); 114 m_agentCircuits.Remove(circuitCode);
108 AgentCircuitsByUUID.Remove(agentID); 115 m_agentCircuitsByUUID.Remove(agentID);
109 } 116 }
110 } 117 }
111 } 118 }
112 119
113 public virtual void RemoveCircuit(UUID agentID) 120 public virtual void RemoveCircuit(UUID agentID)
114 { 121 {
115 lock (AgentCircuits) 122 lock (m_agentCircuits)
116 { 123 {
117 if (AgentCircuitsByUUID.ContainsKey(agentID)) 124 if (m_agentCircuitsByUUID.ContainsKey(agentID))
118 { 125 {
119 uint circuitCode = AgentCircuitsByUUID[agentID].circuitcode; 126 uint circuitCode = m_agentCircuitsByUUID[agentID].circuitcode;
120 AgentCircuits.Remove(circuitCode); 127 m_agentCircuits.Remove(circuitCode);
121 AgentCircuitsByUUID.Remove(agentID); 128 m_agentCircuitsByUUID.Remove(agentID);
122 } 129 }
123 } 130 }
124 } 131 }
125 public AgentCircuitData GetAgentCircuitData(uint circuitCode) 132 public AgentCircuitData GetAgentCircuitData(uint circuitCode)
126 { 133 {
127 AgentCircuitData agentCircuit = null; 134 AgentCircuitData agentCircuit = null;
128 AgentCircuits.TryGetValue(circuitCode, out agentCircuit); 135 m_agentCircuits.TryGetValue(circuitCode, out agentCircuit);
129 return agentCircuit; 136 return agentCircuit;
130 } 137 }
131 138
132 public AgentCircuitData GetAgentCircuitData(UUID agentID) 139 public AgentCircuitData GetAgentCircuitData(UUID agentID)
133 { 140 {
134 AgentCircuitData agentCircuit = null; 141 AgentCircuitData agentCircuit = null;
135 AgentCircuitsByUUID.TryGetValue(agentID, out agentCircuit); 142 m_agentCircuitsByUUID.TryGetValue(agentID, out agentCircuit);
136 return agentCircuit; 143 return agentCircuit;
137 } 144 }
138 145
146 /// <summary>
147 /// Get all current agent circuits indexed by agent UUID.
148 /// </summary>
149 /// <returns></returns>
150 public Dictionary<UUID, AgentCircuitData> GetAgentCircuits()
151 {
152 lock (m_agentCircuitsByUUID)
153 return new Dictionary<UUID, AgentCircuitData>(m_agentCircuitsByUUID);
154 }
155
139 public void UpdateAgentData(AgentCircuitData agentData) 156 public void UpdateAgentData(AgentCircuitData agentData)
140 { 157 {
141 if (AgentCircuits.ContainsKey((uint) agentData.circuitcode)) 158 if (m_agentCircuits.ContainsKey((uint) agentData.circuitcode))
142 { 159 {
143 AgentCircuits[(uint) agentData.circuitcode].firstname = agentData.firstname; 160 m_agentCircuits[(uint) agentData.circuitcode].firstname = agentData.firstname;
144 AgentCircuits[(uint) agentData.circuitcode].lastname = agentData.lastname; 161 m_agentCircuits[(uint) agentData.circuitcode].lastname = agentData.lastname;
145 AgentCircuits[(uint) agentData.circuitcode].startpos = agentData.startpos; 162 m_agentCircuits[(uint) agentData.circuitcode].startpos = agentData.startpos;
146 163
147 // Updated for when we don't know them before calling Scene.NewUserConnection 164 // Updated for when we don't know them before calling Scene.NewUserConnection
148 AgentCircuits[(uint) agentData.circuitcode].SecureSessionID = agentData.SecureSessionID; 165 m_agentCircuits[(uint) agentData.circuitcode].SecureSessionID = agentData.SecureSessionID;
149 AgentCircuits[(uint) agentData.circuitcode].SessionID = agentData.SessionID; 166 m_agentCircuits[(uint) agentData.circuitcode].SessionID = agentData.SessionID;
150 167
151 // m_log.Debug("update user start pos is " + agentData.startpos.X + " , " + agentData.startpos.Y + " , " + agentData.startpos.Z); 168 // m_log.Debug("update user start pos is " + agentData.startpos.X + " , " + agentData.startpos.Y + " , " + agentData.startpos.Z);
152 } 169 }
@@ -159,16 +176,16 @@ namespace OpenSim.Framework
159 /// <param name="newcircuitcode"></param> 176 /// <param name="newcircuitcode"></param>
160 public bool TryChangeCiruitCode(uint circuitcode, uint newcircuitcode) 177 public bool TryChangeCiruitCode(uint circuitcode, uint newcircuitcode)
161 { 178 {
162 lock (AgentCircuits) 179 lock (m_agentCircuits)
163 { 180 {
164 if (AgentCircuits.ContainsKey((uint)circuitcode) && !AgentCircuits.ContainsKey((uint)newcircuitcode)) 181 if (m_agentCircuits.ContainsKey((uint)circuitcode) && !m_agentCircuits.ContainsKey((uint)newcircuitcode))
165 { 182 {
166 AgentCircuitData agentData = AgentCircuits[(uint)circuitcode]; 183 AgentCircuitData agentData = m_agentCircuits[(uint)circuitcode];
167 184
168 agentData.circuitcode = newcircuitcode; 185 agentData.circuitcode = newcircuitcode;
169 186
170 AgentCircuits.Remove((uint)circuitcode); 187 m_agentCircuits.Remove((uint)circuitcode);
171 AgentCircuits.Add(newcircuitcode, agentData); 188 m_agentCircuits.Add(newcircuitcode, agentData);
172 return true; 189 return true;
173 } 190 }
174 } 191 }
@@ -178,17 +195,17 @@ namespace OpenSim.Framework
178 195
179 public void UpdateAgentChildStatus(uint circuitcode, bool childstatus) 196 public void UpdateAgentChildStatus(uint circuitcode, bool childstatus)
180 { 197 {
181 if (AgentCircuits.ContainsKey(circuitcode)) 198 if (m_agentCircuits.ContainsKey(circuitcode))
182 { 199 {
183 AgentCircuits[circuitcode].child = childstatus; 200 m_agentCircuits[circuitcode].child = childstatus;
184 } 201 }
185 } 202 }
186 203
187 public bool GetAgentChildStatus(uint circuitcode) 204 public bool GetAgentChildStatus(uint circuitcode)
188 { 205 {
189 if (AgentCircuits.ContainsKey(circuitcode)) 206 if (m_agentCircuits.ContainsKey(circuitcode))
190 { 207 {
191 return AgentCircuits[circuitcode].child; 208 return m_agentCircuits[circuitcode].child;
192 } 209 }
193 return false; 210 return false;
194 } 211 }
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs
index 4b38a2e..8d98cc9 100644
--- a/OpenSim/Region/Application/OpenSim.cs
+++ b/OpenSim/Region/Application/OpenSim.cs
@@ -1039,7 +1039,7 @@ namespace OpenSim
1039 { 1039 {
1040 //this.HttpServer. 1040 //this.HttpServer.
1041 acd.AppendFormat("{0}:\n", scene.RegionInfo.RegionName); 1041 acd.AppendFormat("{0}:\n", scene.RegionInfo.RegionName);
1042 foreach (AgentCircuitData aCircuit in scene.AuthenticateHandler.AgentCircuits.Values) 1042 foreach (AgentCircuitData aCircuit in scene.AuthenticateHandler.GetAgentCircuits().Values)
1043 acd.AppendFormat("\t{0} {1} ({2})\n", aCircuit.firstname, aCircuit.lastname, (aCircuit.child ? "Child" : "Root")); 1043 acd.AppendFormat("\t{0} {1} ({2})\n", aCircuit.firstname, aCircuit.lastname, (aCircuit.child ? "Child" : "Root"));
1044 } 1044 }
1045 ); 1045 );
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs
index f6a3d1f..57d22bd 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs
@@ -103,15 +103,13 @@ namespace OpenSim.Region.Framework.Scenes.Tests
103 ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1)); 103 ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1));
104 104
105 Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(sp.UUID), Is.Not.Null); 105 Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(sp.UUID), Is.Not.Null);
106 Assert.That(scene.AuthenticateHandler.AgentCircuits.Count, Is.EqualTo(1)); 106 Assert.That(scene.AuthenticateHandler.GetAgentCircuits().Count, Is.EqualTo(1));
107 Assert.That(scene.AuthenticateHandler.AgentCircuitsByUUID.Count, Is.EqualTo(1));
108 107
109 scene.IncomingCloseAgent(sp.UUID); 108 scene.IncomingCloseAgent(sp.UUID);
110 109
111 Assert.That(scene.GetScenePresence(sp.UUID), Is.Null); 110 Assert.That(scene.GetScenePresence(sp.UUID), Is.Null);
112 Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(sp.UUID), Is.Null); 111 Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(sp.UUID), Is.Null);
113 Assert.That(scene.AuthenticateHandler.AgentCircuits.Count, Is.EqualTo(0)); 112 Assert.That(scene.AuthenticateHandler.GetAgentCircuits().Count, Is.EqualTo(0));
114 Assert.That(scene.AuthenticateHandler.AgentCircuitsByUUID.Count, Is.EqualTo(0));
115 } 113 }
116 114
117 /// <summary> 115 /// <summary>