Removed the lock entirely

cpu-performance
Diva Canto 2013-06-11 15:50:12 -07:00
parent a0fed03e10
commit d8da83b4ff
1 changed files with 57 additions and 61 deletions

View File

@ -56,7 +56,6 @@ 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
@ -476,76 +475,73 @@ 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_AddUserLock) lock (m_UserCache)
m_UserCache.TryGetValue(id, out oldUser);
if (oldUser != null)
{ {
lock (m_UserCache) if (creatorData == null || creatorData == String.Empty)
m_UserCache.TryGetValue(id, out oldUser);
if (oldUser != null)
{ {
if (creatorData == null || creatorData == String.Empty) //ignore updates without creator data
{ return;
//ignore updates without creator data
return;
}
//try update unknown users
//and creator's home URL's
if ((oldUser.FirstName == "Unknown" && !creatorData.Contains("Unknown")) || (oldUser.HomeURL != null && !creatorData.StartsWith(oldUser.HomeURL)))
{
lock (m_UserCache)
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);
}
else
{
//we have already a valid user within the cache
return;
}
} }
UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, id); //try update unknown users
//and creator's home URL's
if (account != null) if ((oldUser.FirstName == "Unknown" && !creatorData.Contains("Unknown")) || (oldUser.HomeURL != null && !creatorData.StartsWith(oldUser.HomeURL)))
{ {
AddUser(id, account.FirstName, account.LastName); lock (m_UserCache)
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);
} }
else else
{ {
UserData user = new UserData(); //we have already a valid user within the cache
user.Id = id; return;
if (creatorData != null && creatorData != string.Empty)
{
//creatorData = <endpoint>;<name>
string[] parts = creatorData.Split(';');
if (parts.Length >= 1)
{
user.HomeURL = parts[0];
try
{
Uri uri = new Uri(parts[0]);
user.LastName = "@" + uri.Authority;
}
catch (UriFormatException)
{
m_log.DebugFormat("[SCENE]: Unable to parse Uri {0}", parts[0]);
user.LastName = "@unknown";
}
}
if (parts.Length >= 2)
user.FirstName = parts[1].Replace(' ', '.');
}
else
{
user.FirstName = "Unknown";
user.LastName = "UserUMMAU";
}
AddUserInternal(user);
} }
} }
UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, id);
if (account != null)
{
AddUser(id, account.FirstName, account.LastName);
}
else
{
UserData user = new UserData();
user.Id = id;
if (creatorData != null && creatorData != string.Empty)
{
//creatorData = <endpoint>;<name>
string[] parts = creatorData.Split(';');
if (parts.Length >= 1)
{
user.HomeURL = parts[0];
try
{
Uri uri = new Uri(parts[0]);
user.LastName = "@" + uri.Authority;
}
catch (UriFormatException)
{
m_log.DebugFormat("[SCENE]: Unable to parse Uri {0}", parts[0]);
user.LastName = "@unknown";
}
}
if (parts.Length >= 2)
user.FirstName = parts[1].Replace(' ', '.');
}
else
{
user.FirstName = "Unknown";
user.LastName = "UserUMMAU";
}
AddUserInternal(user);
}
} }
void AddUserInternal(UserData user) void AddUserInternal(UserData user)