aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2013-07-08 18:07:04 +0100
committerJustin Clark-Casey (justincc)2013-07-08 18:07:04 +0100
commita38c2abae4a5262ec0332426c9721b8718d4e85f (patch)
tree6d00821eb2a4b31d9ba08a882c5b9baa61be5176 /OpenSim
parentMerge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff)
downloadopensim-SC_OLD-a38c2abae4a5262ec0332426c9721b8718d4e85f.zip
opensim-SC_OLD-a38c2abae4a5262ec0332426c9721b8718d4e85f.tar.gz
opensim-SC_OLD-a38c2abae4a5262ec0332426c9721b8718d4e85f.tar.bz2
opensim-SC_OLD-a38c2abae4a5262ec0332426c9721b8718d4e85f.tar.xz
Make dictionary read/write locking consistent in CapabilitiesModule, rename two dictionary fields to standard m_ format
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs130
1 files changed, 82 insertions, 48 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs b/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs
index 6ae9448..c8b341b 100644
--- a/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs
@@ -57,8 +57,8 @@ namespace OpenSim.Region.CoreModules.Framework
57 /// </summary> 57 /// </summary>
58 protected Dictionary<UUID, Caps> m_capsObjects = new Dictionary<UUID, Caps>(); 58 protected Dictionary<UUID, Caps> m_capsObjects = new Dictionary<UUID, Caps>();
59 59
60 protected Dictionary<UUID, string> capsPaths = new Dictionary<UUID, string>(); 60 protected Dictionary<UUID, string> m_capsPaths = new Dictionary<UUID, string>();
61 protected Dictionary<UUID, Dictionary<ulong, string>> childrenSeeds 61 protected Dictionary<UUID, Dictionary<ulong, string>> m_childrenSeeds
62 = new Dictionary<UUID, Dictionary<ulong, string>>(); 62 = new Dictionary<UUID, Dictionary<ulong, string>>();
63 63
64 public void Initialise(IConfigSource source) 64 public void Initialise(IConfigSource source)
@@ -105,35 +105,42 @@ namespace OpenSim.Region.CoreModules.Framework
105 if (m_scene.RegionInfo.EstateSettings.IsBanned(agentId)) 105 if (m_scene.RegionInfo.EstateSettings.IsBanned(agentId))
106 return; 106 return;
107 107
108 Caps caps;
108 String capsObjectPath = GetCapsPath(agentId); 109 String capsObjectPath = GetCapsPath(agentId);
109 110
110 if (m_capsObjects.ContainsKey(agentId)) 111 lock (m_capsObjects)
111 { 112 {
112 Caps oldCaps = m_capsObjects[agentId]; 113 if (m_capsObjects.ContainsKey(agentId))
113 114 {
114 m_log.DebugFormat( 115 Caps oldCaps = m_capsObjects[agentId];
115 "[CAPS]: Recreating caps for agent {0}. Old caps path {1}, new caps path {2}. ", 116
116 agentId, oldCaps.CapsObjectPath, capsObjectPath); 117 m_log.DebugFormat(
117 // This should not happen. The caller code is confused. We need to fix that. 118 "[CAPS]: Recreating caps for agent {0}. Old caps path {1}, new caps path {2}. ",
118 // CAPs can never be reregistered, or the client will be confused. 119 agentId, oldCaps.CapsObjectPath, capsObjectPath);
119 // Hence this return here. 120 // This should not happen. The caller code is confused. We need to fix that.
120 //return; 121 // CAPs can never be reregistered, or the client will be confused.
121 } 122 // Hence this return here.
123 //return;
124 }
122 125
123 Caps caps = new Caps(MainServer.Instance, m_scene.RegionInfo.ExternalHostName, 126 caps = new Caps(MainServer.Instance, m_scene.RegionInfo.ExternalHostName,
124 (MainServer.Instance == null) ? 0: MainServer.Instance.Port, 127 (MainServer.Instance == null) ? 0: MainServer.Instance.Port,
125 capsObjectPath, agentId, m_scene.RegionInfo.RegionName); 128 capsObjectPath, agentId, m_scene.RegionInfo.RegionName);
126 129
127 m_capsObjects[agentId] = caps; 130 m_capsObjects[agentId] = caps;
131 }
128 132
129 m_scene.EventManager.TriggerOnRegisterCaps(agentId, caps); 133 m_scene.EventManager.TriggerOnRegisterCaps(agentId, caps);
130 } 134 }
131 135
132 public void RemoveCaps(UUID agentId) 136 public void RemoveCaps(UUID agentId)
133 { 137 {
134 if (childrenSeeds.ContainsKey(agentId)) 138 lock (m_childrenSeeds)
135 { 139 {
136 childrenSeeds.Remove(agentId); 140 if (m_childrenSeeds.ContainsKey(agentId))
141 {
142 m_childrenSeeds.Remove(agentId);
143 }
137 } 144 }
138 145
139 lock (m_capsObjects) 146 lock (m_capsObjects)
@@ -168,16 +175,22 @@ namespace OpenSim.Region.CoreModules.Framework
168 175
169 public void SetAgentCapsSeeds(AgentCircuitData agent) 176 public void SetAgentCapsSeeds(AgentCircuitData agent)
170 { 177 {
171 capsPaths[agent.AgentID] = agent.CapsPath; 178 lock (m_capsPaths)
172 childrenSeeds[agent.AgentID] 179 m_capsPaths[agent.AgentID] = agent.CapsPath;
173 = ((agent.ChildrenCapSeeds == null) ? new Dictionary<ulong, string>() : agent.ChildrenCapSeeds); 180
181 lock (m_childrenSeeds)
182 m_childrenSeeds[agent.AgentID]
183 = ((agent.ChildrenCapSeeds == null) ? new Dictionary<ulong, string>() : agent.ChildrenCapSeeds);
174 } 184 }
175 185
176 public string GetCapsPath(UUID agentId) 186 public string GetCapsPath(UUID agentId)
177 { 187 {
178 if (capsPaths.ContainsKey(agentId)) 188 lock (m_capsPaths)
179 { 189 {
180 return capsPaths[agentId]; 190 if (m_capsPaths.ContainsKey(agentId))
191 {
192 return m_capsPaths[agentId];
193 }
181 } 194 }
182 195
183 return null; 196 return null;
@@ -186,17 +199,24 @@ namespace OpenSim.Region.CoreModules.Framework
186 public Dictionary<ulong, string> GetChildrenSeeds(UUID agentID) 199 public Dictionary<ulong, string> GetChildrenSeeds(UUID agentID)
187 { 200 {
188 Dictionary<ulong, string> seeds = null; 201 Dictionary<ulong, string> seeds = null;
189 if (childrenSeeds.TryGetValue(agentID, out seeds)) 202
190 return seeds; 203 lock (m_childrenSeeds)
204 if (m_childrenSeeds.TryGetValue(agentID, out seeds))
205 return seeds;
206
191 return new Dictionary<ulong, string>(); 207 return new Dictionary<ulong, string>();
192 } 208 }
193 209
194 public void DropChildSeed(UUID agentID, ulong handle) 210 public void DropChildSeed(UUID agentID, ulong handle)
195 { 211 {
196 Dictionary<ulong, string> seeds; 212 Dictionary<ulong, string> seeds;
197 if (childrenSeeds.TryGetValue(agentID, out seeds)) 213
214 lock (m_childrenSeeds)
198 { 215 {
199 seeds.Remove(handle); 216 if (m_childrenSeeds.TryGetValue(agentID, out seeds))
217 {
218 seeds.Remove(handle);
219 }
200 } 220 }
201 } 221 }
202 222
@@ -204,30 +224,41 @@ namespace OpenSim.Region.CoreModules.Framework
204 { 224 {
205 Dictionary<ulong, string> seeds; 225 Dictionary<ulong, string> seeds;
206 string returnval; 226 string returnval;
207 if (childrenSeeds.TryGetValue(agentID, out seeds)) 227
228 lock (m_childrenSeeds)
208 { 229 {
209 if (seeds.TryGetValue(handle, out returnval)) 230 if (m_childrenSeeds.TryGetValue(agentID, out seeds))
210 return returnval; 231 {
232 if (seeds.TryGetValue(handle, out returnval))
233 return returnval;
234 }
211 } 235 }
236
212 return null; 237 return null;
213 } 238 }
214 239
215 public void SetChildrenSeed(UUID agentID, Dictionary<ulong, string> seeds) 240 public void SetChildrenSeed(UUID agentID, Dictionary<ulong, string> seeds)
216 { 241 {
217 //m_log.DebugFormat(" !!! Setting child seeds in {0} to {1}", m_scene.RegionInfo.RegionName, seeds.Count); 242 //m_log.DebugFormat(" !!! Setting child seeds in {0} to {1}", m_scene.RegionInfo.RegionName, seeds.Count);
218 childrenSeeds[agentID] = seeds; 243
244 lock (m_childrenSeeds)
245 m_childrenSeeds[agentID] = seeds;
219 } 246 }
220 247
221 public void DumpChildrenSeeds(UUID agentID) 248 public void DumpChildrenSeeds(UUID agentID)
222 { 249 {
223 m_log.Info("================ ChildrenSeed "+m_scene.RegionInfo.RegionName+" ================"); 250 m_log.Info("================ ChildrenSeed "+m_scene.RegionInfo.RegionName+" ================");
224 foreach (KeyValuePair<ulong, string> kvp in childrenSeeds[agentID]) 251
252 lock (m_childrenSeeds)
225 { 253 {
226 uint x, y; 254 foreach (KeyValuePair<ulong, string> kvp in m_childrenSeeds[agentID])
227 Utils.LongToUInts(kvp.Key, out x, out y); 255 {
228 x = x / Constants.RegionSize; 256 uint x, y;
229 y = y / Constants.RegionSize; 257 Utils.LongToUInts(kvp.Key, out x, out y);
230 m_log.Info(" >> "+x+", "+y+": "+kvp.Value); 258 x = x / Constants.RegionSize;
259 y = y / Constants.RegionSize;
260 m_log.Info(" >> "+x+", "+y+": "+kvp.Value);
261 }
231 } 262 }
232 } 263 }
233 264
@@ -236,21 +267,24 @@ namespace OpenSim.Region.CoreModules.Framework
236 StringBuilder caps = new StringBuilder(); 267 StringBuilder caps = new StringBuilder();
237 caps.AppendFormat("Region {0}:\n", m_scene.RegionInfo.RegionName); 268 caps.AppendFormat("Region {0}:\n", m_scene.RegionInfo.RegionName);
238 269
239 foreach (KeyValuePair<UUID, Caps> kvp in m_capsObjects) 270 lock (m_capsObjects)
240 { 271 {
241 caps.AppendFormat("** User {0}:\n", kvp.Key); 272 foreach (KeyValuePair<UUID, Caps> kvp in m_capsObjects)
242
243 for (IDictionaryEnumerator kvp2 = kvp.Value.CapsHandlers.GetCapsDetails(false, null).GetEnumerator(); kvp2.MoveNext(); )
244 { 273 {
245 Uri uri = new Uri(kvp2.Value.ToString()); 274 caps.AppendFormat("** User {0}:\n", kvp.Key);
246 caps.AppendFormat(m_showCapsCommandFormat, kvp2.Key, uri.PathAndQuery); 275
247 } 276 for (IDictionaryEnumerator kvp2 = kvp.Value.CapsHandlers.GetCapsDetails(false, null).GetEnumerator(); kvp2.MoveNext(); )
277 {
278 Uri uri = new Uri(kvp2.Value.ToString());
279 caps.AppendFormat(m_showCapsCommandFormat, kvp2.Key, uri.PathAndQuery);
280 }
248 281
249 foreach (KeyValuePair<string, string> kvp3 in kvp.Value.ExternalCapsHandlers) 282 foreach (KeyValuePair<string, string> kvp3 in kvp.Value.ExternalCapsHandlers)
250 caps.AppendFormat(m_showCapsCommandFormat, kvp3.Key, kvp3.Value); 283 caps.AppendFormat(m_showCapsCommandFormat, kvp3.Key, kvp3.Value);
284 }
251 } 285 }
252 286
253 MainConsole.Instance.Output(caps.ToString()); 287 MainConsole.Instance.Output(caps.ToString());
254 } 288 }
255 } 289 }
256} 290} \ No newline at end of file