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
cpu-performance
Justin Clark-Casey (justincc) 2013-06-15 00:52:57 +01:00
parent 42b0c68eab
commit e6cb7b4764
1 changed files with 13 additions and 14 deletions

View File

@ -331,18 +331,17 @@ namespace OpenSim.Region.OptionalModules.Avatar.UserProfiles
classifieds[cid] = name;
lock (m_classifiedCache)
{
if (!m_classifiedCache.ContainsKey(cid))
{
lock(m_classifiedCache)
m_classifiedCache.Add(cid,creatorId);
lock(m_classifiedInterest)
m_classifiedInterest.Add(cid, 0);
}
lock(m_classifiedInterest)
m_classifiedInterest[cid]++;
}
}
remoteClient.SendAvatarClassifiedReply(new UUID(args[0]), classifieds);
}
@ -353,21 +352,21 @@ namespace OpenSim.Region.OptionalModules.Avatar.UserProfiles
UserClassifiedAdd ad = new UserClassifiedAdd();
ad.ClassifiedId = queryClassifiedID;
lock (m_classifiedCache)
{
if (m_classifiedCache.ContainsKey(queryClassifiedID))
{
target = m_classifiedCache[queryClassifiedID];
lock(m_classifiedInterest)
m_classifiedInterest[queryClassifiedID] --;
if (m_classifiedInterest[queryClassifiedID] == 0)
{
lock(m_classifiedInterest)
m_classifiedInterest.Remove(queryClassifiedID);
lock(m_classifiedCache)
m_classifiedCache.Remove(queryClassifiedID);
}
}
}
string serverURI = string.Empty;
bool foreign = GetUserProfileServerURI(target, out serverURI);