From 9618c196c274fefda4437eff6d25c7a12e7a3ee1 Mon Sep 17 00:00:00 2001
From: Melanie
Date: Wed, 7 Oct 2009 01:44:36 +0100
Subject: Revert "Merging in diva's locking fixes"
This reverts commit 832cc685138b2244529f10b54b373c34adb4a633.
---
.../Cache/UserProfileCacheService.cs | 66 +++++++++++++---------
1 file changed, 39 insertions(+), 27 deletions(-)
(limited to 'OpenSim/Framework/Communications')
diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs
index b02cf5b..9e12d948 100644
--- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs
+++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs
@@ -128,18 +128,24 @@ namespace OpenSim.Framework.Communications.Cache
/// null if no user details are found
public CachedUserInfo GetUserDetails(string fname, string lname)
{
- CachedUserInfo userInfo;
lock (m_userProfilesByName)
- {
+ {
+ CachedUserInfo userInfo;
+
if (m_userProfilesByName.TryGetValue(string.Format(NAME_FORMAT, fname, lname), out userInfo))
+ {
return userInfo;
+ }
+ else
+ {
+ UserProfileData userProfile = m_commsManager.UserService.GetUserProfile(fname, lname);
+
+ if (userProfile != null)
+ return AddToCaches(userProfile);
+ else
+ return null;
+ }
}
- UserProfileData userProfile = m_commsManager.UserService.GetUserProfile(fname, lname);
-
- if (userProfile != null)
- return AddToCaches(userProfile);
- else
- return null;
}
///
@@ -154,14 +160,20 @@ namespace OpenSim.Framework.Communications.Cache
return null;
lock (m_userProfilesById)
+ {
if (m_userProfilesById.ContainsKey(userID))
+ {
return m_userProfilesById[userID];
-
- UserProfileData userProfile = m_commsManager.UserService.GetUserProfile(userID);
- if (userProfile != null)
- return AddToCaches(userProfile);
- else
- return null;
+ }
+ else
+ {
+ UserProfileData userProfile = m_commsManager.UserService.GetUserProfile(userID);
+ if (userProfile != null)
+ return AddToCaches(userProfile);
+ else
+ return null;
+ }
+ }
}
///
@@ -199,10 +211,14 @@ namespace OpenSim.Framework.Communications.Cache
CachedUserInfo createdUserInfo = new CachedUserInfo(m_InventoryService, userProfile);
lock (m_userProfilesById)
+ {
m_userProfilesById[createdUserInfo.UserProfile.ID] = createdUserInfo;
-
- lock (m_userProfilesByName)
- m_userProfilesByName[createdUserInfo.UserProfile.Name] = createdUserInfo;
+
+ lock (m_userProfilesByName)
+ {
+ m_userProfilesByName[createdUserInfo.UserProfile.Name] = createdUserInfo;
+ }
+ }
return createdUserInfo;
}
@@ -214,25 +230,21 @@ namespace OpenSim.Framework.Communications.Cache
/// true if there was a profile to remove, false otherwise
protected bool RemoveFromCaches(UUID userId)
{
- CachedUserInfo userInfo = null;
lock (m_userProfilesById)
{
if (m_userProfilesById.ContainsKey(userId))
{
- userInfo = m_userProfilesById[userId];
+ CachedUserInfo userInfo = m_userProfilesById[userId];
m_userProfilesById.Remove(userId);
- }
- }
-
- if (userInfo != null)
- lock (m_userProfilesByName)
- {
- if (m_userProfilesByName.ContainsKey(userInfo.UserProfile.Name))
+
+ lock (m_userProfilesByName)
{
m_userProfilesByName.Remove(userInfo.UserProfile.Name);
- return true;
}
+
+ return true;
}
+ }
return false;
}
--
cgit v1.1