From b4f472c4fab5c1b3fda0f86bba330d5bf0800e22 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Wed, 5 Jun 2013 15:08:25 -0400 Subject: [PATCH 1/2] Make locking more uniform --- .../Avatar/UserProfiles/UserProfileModule.cs | 39 +++++++++++-------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs index 5b228ee6d4..7165cb67f4 100644 --- a/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs @@ -62,6 +62,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.UserProfiles // count. The entries are removed when the interest count reaches 0. Dictionary classifiedCache = new Dictionary(); Dictionary classifiedInterest = new Dictionary(); + Object classifiedLock; public Scene Scene { @@ -326,14 +327,20 @@ namespace OpenSim.Region.OptionalModules.Avatar.UserProfiles string name = m["name"].AsString(); classifieds[cid] = name; - + if(!classifiedCache.ContainsKey(cid)) { - classifiedCache.Add(cid,creatorId); - classifiedInterest.Add(cid, 0); +// lock(classifiedLock) +// { + lock(classifiedCache) + classifiedCache.Add(cid,creatorId); + lock(classifiedInterest) + classifiedInterest.Add(cid, 0); +// } } - classifiedInterest[cid] ++; + lock(classifiedInterest) + classifiedInterest[cid] ++; } remoteClient.SendAvatarClassifiedReply(new UUID(args[0]), classifieds); @@ -346,22 +353,20 @@ namespace OpenSim.Region.OptionalModules.Avatar.UserProfiles ad.ClassifiedId = queryClassifiedID; if(classifiedCache.ContainsKey(queryClassifiedID)) - { + { target = classifiedCache[queryClassifiedID]; - if(classifiedInterest[queryClassifiedID] -- == 0) - { - lock(classifiedCache) - { - lock(classifiedInterest) - { - classifiedInterest.Remove(queryClassifiedID); - } - classifiedCache.Remove(queryClassifiedID); - } - } - } + lock(classifiedInterest) + classifiedInterest[queryClassifiedID] --; + if(classifiedInterest[queryClassifiedID] == 0) + { + lock(classifiedInterest) + classifiedInterest.Remove(queryClassifiedID); + lock(classifiedCache) + classifiedCache.Remove(queryClassifiedID); + } + } string serverURI = string.Empty; bool foreign = GetUserProfileServerURI(target, out serverURI); From 10572b78f8d726ff07fd37dca4bb4f27f38563cb Mon Sep 17 00:00:00 2001 From: BlueWall Date: Wed, 5 Jun 2013 15:10:53 -0400 Subject: [PATCH 2/2] Remove a couple of orphaned lines --- .../CoreModules/Avatar/UserProfiles/UserProfileModule.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs index 7165cb67f4..13f0167b4b 100644 --- a/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs @@ -330,13 +330,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.UserProfiles if(!classifiedCache.ContainsKey(cid)) { -// lock(classifiedLock) -// { lock(classifiedCache) classifiedCache.Add(cid,creatorId); lock(classifiedInterest) classifiedInterest.Add(cid, 0); -// } } lock(classifiedInterest)