diff options
author | Justin Clark-Casey (justincc) | 2013-06-15 00:52:57 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2013-06-15 00:52:57 +0100 |
commit | e6cb7b47646f8d7a23aca50d92fb57a639bbf702 (patch) | |
tree | 9610eb760dafe25828072d6e504e34598cd09748 | |
parent | Correct build break in previous commit 9c530d7 (diff) | |
download | opensim-SC_OLD-e6cb7b47646f8d7a23aca50d92fb57a639bbf702.zip opensim-SC_OLD-e6cb7b47646f8d7a23aca50d92fb57a639bbf702.tar.gz opensim-SC_OLD-e6cb7b47646f8d7a23aca50d92fb57a639bbf702.tar.bz2 opensim-SC_OLD-e6cb7b47646f8d7a23aca50d92fb57a639bbf702.tar.xz |
Lock m_classifiedCache and m_classifiedInterest dictionary reads in UserProfileModule since in the presence of writes these are not thread-safe operations.
Simplified locking to m_classifiedCache only since r/w of both dictionaries always occurs together
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs index d7ffea8..161f160 100644 --- a/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs | |||
@@ -331,17 +331,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.UserProfiles | |||
331 | 331 | ||
332 | classifieds[cid] = name; | 332 | classifieds[cid] = name; |
333 | 333 | ||
334 | if (!m_classifiedCache.ContainsKey(cid)) | 334 | lock (m_classifiedCache) |
335 | { | 335 | { |
336 | lock(m_classifiedCache) | 336 | if (!m_classifiedCache.ContainsKey(cid)) |
337 | { | ||
337 | m_classifiedCache.Add(cid,creatorId); | 338 | m_classifiedCache.Add(cid,creatorId); |
338 | |||
339 | lock(m_classifiedInterest) | ||
340 | m_classifiedInterest.Add(cid, 0); | 339 | m_classifiedInterest.Add(cid, 0); |
341 | } | 340 | } |
342 | 341 | ||
343 | lock(m_classifiedInterest) | ||
344 | m_classifiedInterest[cid]++; | 342 | m_classifiedInterest[cid]++; |
343 | } | ||
345 | } | 344 | } |
346 | 345 | ||
347 | remoteClient.SendAvatarClassifiedReply(new UUID(args[0]), classifieds); | 346 | remoteClient.SendAvatarClassifiedReply(new UUID(args[0]), classifieds); |
@@ -353,19 +352,19 @@ namespace OpenSim.Region.OptionalModules.Avatar.UserProfiles | |||
353 | UserClassifiedAdd ad = new UserClassifiedAdd(); | 352 | UserClassifiedAdd ad = new UserClassifiedAdd(); |
354 | ad.ClassifiedId = queryClassifiedID; | 353 | ad.ClassifiedId = queryClassifiedID; |
355 | 354 | ||
356 | if (m_classifiedCache.ContainsKey(queryClassifiedID)) | 355 | lock (m_classifiedCache) |
357 | { | 356 | { |
358 | target = m_classifiedCache[queryClassifiedID]; | 357 | if (m_classifiedCache.ContainsKey(queryClassifiedID)) |
358 | { | ||
359 | target = m_classifiedCache[queryClassifiedID]; | ||
359 | 360 | ||
360 | lock(m_classifiedInterest) | ||
361 | m_classifiedInterest[queryClassifiedID] --; | 361 | m_classifiedInterest[queryClassifiedID] --; |
362 | 362 | ||
363 | if(m_classifiedInterest[queryClassifiedID] == 0) | 363 | if (m_classifiedInterest[queryClassifiedID] == 0) |
364 | { | 364 | { |
365 | lock(m_classifiedInterest) | ||
366 | m_classifiedInterest.Remove(queryClassifiedID); | 365 | m_classifiedInterest.Remove(queryClassifiedID); |
367 | lock(m_classifiedCache) | ||
368 | m_classifiedCache.Remove(queryClassifiedID); | 366 | m_classifiedCache.Remove(queryClassifiedID); |
367 | } | ||
369 | } | 368 | } |
370 | } | 369 | } |
371 | 370 | ||