Really bad idea to lock m_UserCache for so long in UserManagementModule. Added a special lock object instead, if we really want to avoid concurrent executions of that code.

cpu-performance
Diva Canto 2013-06-11 15:36:27 -07:00
parent 57141e34bf
commit b33db917f5
1 changed files with 17 additions and 13 deletions

View File

@ -56,6 +56,7 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
// The cache // The cache
protected Dictionary<UUID, UserData> m_UserCache = new Dictionary<UUID, UserData>(); protected Dictionary<UUID, UserData> m_UserCache = new Dictionary<UUID, UserData>();
private object m_AddUserLock = new object();
#region ISharedRegionModule #region ISharedRegionModule
@ -475,9 +476,11 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
UserData oldUser; UserData oldUser;
//lock the whole block - prevent concurrent update //lock the whole block - prevent concurrent update
lock (m_UserCache) lock (m_AddUserLock)
{ {
lock (m_UserCache)
m_UserCache.TryGetValue(id, out oldUser); m_UserCache.TryGetValue(id, out oldUser);
if (oldUser != null) if (oldUser != null)
{ {
if (creatorData == null || creatorData == String.Empty) if (creatorData == null || creatorData == String.Empty)
@ -490,6 +493,7 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
//and creator's home URL's //and creator's home URL's
if ((oldUser.FirstName == "Unknown" && !creatorData.Contains("Unknown")) || (oldUser.HomeURL != null && !creatorData.StartsWith(oldUser.HomeURL))) if ((oldUser.FirstName == "Unknown" && !creatorData.Contains("Unknown")) || (oldUser.HomeURL != null && !creatorData.StartsWith(oldUser.HomeURL)))
{ {
lock (m_UserCache)
m_UserCache.Remove(id); m_UserCache.Remove(id);
m_log.DebugFormat("[USER MANAGEMENT MODULE]: Re-adding user with id {0}, creatorData [{1}] and old HomeURL {2}", id, creatorData, oldUser.HomeURL); m_log.DebugFormat("[USER MANAGEMENT MODULE]: Re-adding user with id {0}, creatorData [{1}] and old HomeURL {2}", id, creatorData, oldUser.HomeURL);
} }