diff options
author | Justin Clark-Casey (justincc) | 2011-12-03 16:19:11 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2011-12-03 16:19:11 +0000 |
commit | ced820bd5e0fe9c20309fe1a3cb91f9ee316ec22 (patch) | |
tree | 97f40a0ed782013b42a133206c19bcedab9e7205 /OpenSim/Framework | |
parent | Use GetAgentCircuits() to receive a copy of the AgentCircuitsByUUID dictionar... (diff) | |
download | opensim-SC_OLD-ced820bd5e0fe9c20309fe1a3cb91f9ee316ec22.zip opensim-SC_OLD-ced820bd5e0fe9c20309fe1a3cb91f9ee316ec22.tar.gz opensim-SC_OLD-ced820bd5e0fe9c20309fe1a3cb91f9ee316ec22.tar.bz2 opensim-SC_OLD-ced820bd5e0fe9c20309fe1a3cb91f9ee316ec22.tar.xz |
Improve locking in AgentCircuitManager
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r-- | OpenSim/Framework/AgentCircuitManager.cs | 66 |
1 files changed, 41 insertions, 25 deletions
diff --git a/OpenSim/Framework/AgentCircuitManager.cs b/OpenSim/Framework/AgentCircuitManager.cs index a59bcfa..b6e48b4 100644 --- a/OpenSim/Framework/AgentCircuitManager.cs +++ b/OpenSim/Framework/AgentCircuitManager.cs | |||
@@ -38,6 +38,9 @@ namespace OpenSim.Framework | |||
38 | /// <summary> | 38 | /// <summary> |
39 | /// Agent circuits indexed by circuit code. | 39 | /// Agent circuits indexed by circuit code. |
40 | /// </summary> | 40 | /// </summary> |
41 | /// <remarks> | ||
42 | /// We lock this for operations both on this dictionary and on m_agentCircuitsByUUID | ||
43 | /// </remarks> | ||
41 | private Dictionary<uint, AgentCircuitData> m_agentCircuits = new Dictionary<uint, AgentCircuitData>(); | 44 | private Dictionary<uint, AgentCircuitData> m_agentCircuits = new Dictionary<uint, AgentCircuitData>(); |
42 | 45 | ||
43 | /// <summary> | 46 | /// <summary> |
@@ -48,16 +51,20 @@ namespace OpenSim.Framework | |||
48 | public virtual AuthenticateResponse AuthenticateSession(UUID sessionID, UUID agentID, uint circuitcode) | 51 | public virtual AuthenticateResponse AuthenticateSession(UUID sessionID, UUID agentID, uint circuitcode) |
49 | { | 52 | { |
50 | AgentCircuitData validcircuit = null; | 53 | AgentCircuitData validcircuit = null; |
51 | if (m_agentCircuits.ContainsKey(circuitcode)) | 54 | |
55 | lock (m_agentCircuits) | ||
52 | { | 56 | { |
53 | validcircuit = m_agentCircuits[circuitcode]; | 57 | if (m_agentCircuits.ContainsKey(circuitcode)) |
58 | validcircuit = m_agentCircuits[circuitcode]; | ||
54 | } | 59 | } |
60 | |||
55 | AuthenticateResponse user = new AuthenticateResponse(); | 61 | AuthenticateResponse user = new AuthenticateResponse(); |
62 | |||
56 | if (validcircuit == null) | 63 | if (validcircuit == null) |
57 | { | 64 | { |
58 | //don't have this circuit code in our list | 65 | //don't have this circuit code in our list |
59 | user.Authorised = false; | 66 | user.Authorised = false; |
60 | return (user); | 67 | return user; |
61 | } | 68 | } |
62 | 69 | ||
63 | if ((sessionID == validcircuit.SessionID) && (agentID == validcircuit.AgentID)) | 70 | if ((sessionID == validcircuit.SessionID) && (agentID == validcircuit.AgentID)) |
@@ -79,7 +86,7 @@ namespace OpenSim.Framework | |||
79 | user.Authorised = false; | 86 | user.Authorised = false; |
80 | } | 87 | } |
81 | 88 | ||
82 | return (user); | 89 | return user; |
83 | } | 90 | } |
84 | 91 | ||
85 | /// <summary> | 92 | /// <summary> |
@@ -129,17 +136,24 @@ namespace OpenSim.Framework | |||
129 | } | 136 | } |
130 | } | 137 | } |
131 | } | 138 | } |
139 | |||
132 | public AgentCircuitData GetAgentCircuitData(uint circuitCode) | 140 | public AgentCircuitData GetAgentCircuitData(uint circuitCode) |
133 | { | 141 | { |
134 | AgentCircuitData agentCircuit = null; | 142 | AgentCircuitData agentCircuit = null; |
135 | m_agentCircuits.TryGetValue(circuitCode, out agentCircuit); | 143 | |
144 | lock (m_agentCircuits) | ||
145 | m_agentCircuits.TryGetValue(circuitCode, out agentCircuit); | ||
146 | |||
136 | return agentCircuit; | 147 | return agentCircuit; |
137 | } | 148 | } |
138 | 149 | ||
139 | public AgentCircuitData GetAgentCircuitData(UUID agentID) | 150 | public AgentCircuitData GetAgentCircuitData(UUID agentID) |
140 | { | 151 | { |
141 | AgentCircuitData agentCircuit = null; | 152 | AgentCircuitData agentCircuit = null; |
142 | m_agentCircuitsByUUID.TryGetValue(agentID, out agentCircuit); | 153 | |
154 | lock (m_agentCircuits) | ||
155 | m_agentCircuitsByUUID.TryGetValue(agentID, out agentCircuit); | ||
156 | |||
143 | return agentCircuit; | 157 | return agentCircuit; |
144 | } | 158 | } |
145 | 159 | ||
@@ -149,23 +163,26 @@ namespace OpenSim.Framework | |||
149 | /// <returns></returns> | 163 | /// <returns></returns> |
150 | public Dictionary<UUID, AgentCircuitData> GetAgentCircuits() | 164 | public Dictionary<UUID, AgentCircuitData> GetAgentCircuits() |
151 | { | 165 | { |
152 | lock (m_agentCircuitsByUUID) | 166 | lock (m_agentCircuits) |
153 | return new Dictionary<UUID, AgentCircuitData>(m_agentCircuitsByUUID); | 167 | return new Dictionary<UUID, AgentCircuitData>(m_agentCircuitsByUUID); |
154 | } | 168 | } |
155 | 169 | ||
156 | public void UpdateAgentData(AgentCircuitData agentData) | 170 | public void UpdateAgentData(AgentCircuitData agentData) |
157 | { | 171 | { |
158 | if (m_agentCircuits.ContainsKey((uint) agentData.circuitcode)) | 172 | lock (m_agentCircuits) |
159 | { | 173 | { |
160 | m_agentCircuits[(uint) agentData.circuitcode].firstname = agentData.firstname; | 174 | if (m_agentCircuits.ContainsKey((uint) agentData.circuitcode)) |
161 | m_agentCircuits[(uint) agentData.circuitcode].lastname = agentData.lastname; | 175 | { |
162 | m_agentCircuits[(uint) agentData.circuitcode].startpos = agentData.startpos; | 176 | m_agentCircuits[(uint) agentData.circuitcode].firstname = agentData.firstname; |
177 | m_agentCircuits[(uint) agentData.circuitcode].lastname = agentData.lastname; | ||
178 | m_agentCircuits[(uint) agentData.circuitcode].startpos = agentData.startpos; | ||
163 | 179 | ||
164 | // Updated for when we don't know them before calling Scene.NewUserConnection | 180 | // Updated for when we don't know them before calling Scene.NewUserConnection |
165 | m_agentCircuits[(uint) agentData.circuitcode].SecureSessionID = agentData.SecureSessionID; | 181 | m_agentCircuits[(uint) agentData.circuitcode].SecureSessionID = agentData.SecureSessionID; |
166 | m_agentCircuits[(uint) agentData.circuitcode].SessionID = agentData.SessionID; | 182 | m_agentCircuits[(uint) agentData.circuitcode].SessionID = agentData.SessionID; |
167 | 183 | ||
168 | // m_log.Debug("update user start pos is " + agentData.startpos.X + " , " + agentData.startpos.Y + " , " + agentData.startpos.Z); | 184 | // m_log.Debug("update user start pos is " + agentData.startpos.X + " , " + agentData.startpos.Y + " , " + agentData.startpos.Z); |
185 | } | ||
169 | } | 186 | } |
170 | } | 187 | } |
171 | 188 | ||
@@ -189,25 +206,24 @@ namespace OpenSim.Framework | |||
189 | return true; | 206 | return true; |
190 | } | 207 | } |
191 | } | 208 | } |
192 | return false; | ||
193 | 209 | ||
210 | return false; | ||
194 | } | 211 | } |
195 | 212 | ||
196 | public void UpdateAgentChildStatus(uint circuitcode, bool childstatus) | 213 | public void UpdateAgentChildStatus(uint circuitcode, bool childstatus) |
197 | { | 214 | { |
198 | if (m_agentCircuits.ContainsKey(circuitcode)) | 215 | lock (m_agentCircuits) |
199 | { | 216 | if (m_agentCircuits.ContainsKey(circuitcode)) |
200 | m_agentCircuits[circuitcode].child = childstatus; | 217 | m_agentCircuits[circuitcode].child = childstatus; |
201 | } | ||
202 | } | 218 | } |
203 | 219 | ||
204 | public bool GetAgentChildStatus(uint circuitcode) | 220 | public bool GetAgentChildStatus(uint circuitcode) |
205 | { | 221 | { |
206 | if (m_agentCircuits.ContainsKey(circuitcode)) | 222 | lock (m_agentCircuits) |
207 | { | 223 | if (m_agentCircuits.ContainsKey(circuitcode)) |
208 | return m_agentCircuits[circuitcode].child; | 224 | return m_agentCircuits[circuitcode].child; |
209 | } | 225 | |
210 | return false; | 226 | return false; |
211 | } | 227 | } |
212 | } | 228 | } |
213 | } | 229 | } \ No newline at end of file |