aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Communications/Cache
diff options
context:
space:
mode:
authorDiva Canto2009-10-06 15:39:53 -0700
committerDiva Canto2009-10-06 15:39:53 -0700
commite992ca025571a891333a57012c2cd4419b6581e5 (patch)
treea6fd7e9f2e46999c72780bf60d2890e8a9c74fe4 /OpenSim/Framework/Communications/Cache
parent* Change some more default ports to the robust default of 8003 (diff)
downloadopensim-SC-e992ca025571a891333a57012c2cd4419b6581e5.zip
opensim-SC-e992ca025571a891333a57012c2cd4419b6581e5.tar.gz
opensim-SC-e992ca025571a891333a57012c2cd4419b6581e5.tar.bz2
opensim-SC-e992ca025571a891333a57012c2cd4419b6581e5.tar.xz
Rewrote parts of the code that were double-locking different objects. This is about half of the code base reviewed.
Diffstat (limited to 'OpenSim/Framework/Communications/Cache')
-rw-r--r--OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs66
1 files changed, 27 insertions, 39 deletions
diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs
index 9e12d948..b02cf5b 100644
--- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs
+++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs
@@ -128,24 +128,18 @@ namespace OpenSim.Framework.Communications.Cache
128 /// <returns>null if no user details are found</returns> 128 /// <returns>null if no user details are found</returns>
129 public CachedUserInfo GetUserDetails(string fname, string lname) 129 public CachedUserInfo GetUserDetails(string fname, string lname)
130 { 130 {
131 CachedUserInfo userInfo;
131 lock (m_userProfilesByName) 132 lock (m_userProfilesByName)
132 { 133 {
133 CachedUserInfo userInfo;
134
135 if (m_userProfilesByName.TryGetValue(string.Format(NAME_FORMAT, fname, lname), out userInfo)) 134 if (m_userProfilesByName.TryGetValue(string.Format(NAME_FORMAT, fname, lname), out userInfo))
136 {
137 return userInfo; 135 return userInfo;
138 }
139 else
140 {
141 UserProfileData userProfile = m_commsManager.UserService.GetUserProfile(fname, lname);
142
143 if (userProfile != null)
144 return AddToCaches(userProfile);
145 else
146 return null;
147 }
148 } 136 }
137 UserProfileData userProfile = m_commsManager.UserService.GetUserProfile(fname, lname);
138
139 if (userProfile != null)
140 return AddToCaches(userProfile);
141 else
142 return null;
149 } 143 }
150 144
151 /// <summary> 145 /// <summary>
@@ -160,20 +154,14 @@ namespace OpenSim.Framework.Communications.Cache
160 return null; 154 return null;
161 155
162 lock (m_userProfilesById) 156 lock (m_userProfilesById)
163 {
164 if (m_userProfilesById.ContainsKey(userID)) 157 if (m_userProfilesById.ContainsKey(userID))
165 {
166 return m_userProfilesById[userID]; 158 return m_userProfilesById[userID];
167 } 159
168 else 160 UserProfileData userProfile = m_commsManager.UserService.GetUserProfile(userID);
169 { 161 if (userProfile != null)
170 UserProfileData userProfile = m_commsManager.UserService.GetUserProfile(userID); 162 return AddToCaches(userProfile);
171 if (userProfile != null) 163 else
172 return AddToCaches(userProfile); 164 return null;
173 else
174 return null;
175 }
176 }
177 } 165 }
178 166
179 /// <summary> 167 /// <summary>
@@ -211,14 +199,10 @@ namespace OpenSim.Framework.Communications.Cache
211 CachedUserInfo createdUserInfo = new CachedUserInfo(m_InventoryService, userProfile); 199 CachedUserInfo createdUserInfo = new CachedUserInfo(m_InventoryService, userProfile);
212 200
213 lock (m_userProfilesById) 201 lock (m_userProfilesById)
214 {
215 m_userProfilesById[createdUserInfo.UserProfile.ID] = createdUserInfo; 202 m_userProfilesById[createdUserInfo.UserProfile.ID] = createdUserInfo;
216 203
217 lock (m_userProfilesByName) 204 lock (m_userProfilesByName)
218 { 205 m_userProfilesByName[createdUserInfo.UserProfile.Name] = createdUserInfo;
219 m_userProfilesByName[createdUserInfo.UserProfile.Name] = createdUserInfo;
220 }
221 }
222 206
223 return createdUserInfo; 207 return createdUserInfo;
224 } 208 }
@@ -230,21 +214,25 @@ namespace OpenSim.Framework.Communications.Cache
230 /// <returns>true if there was a profile to remove, false otherwise</returns> 214 /// <returns>true if there was a profile to remove, false otherwise</returns>
231 protected bool RemoveFromCaches(UUID userId) 215 protected bool RemoveFromCaches(UUID userId)
232 { 216 {
217 CachedUserInfo userInfo = null;
233 lock (m_userProfilesById) 218 lock (m_userProfilesById)
234 { 219 {
235 if (m_userProfilesById.ContainsKey(userId)) 220 if (m_userProfilesById.ContainsKey(userId))
236 { 221 {
237 CachedUserInfo userInfo = m_userProfilesById[userId]; 222 userInfo = m_userProfilesById[userId];
238 m_userProfilesById.Remove(userId); 223 m_userProfilesById.Remove(userId);
239 224 }
240 lock (m_userProfilesByName) 225 }
226
227 if (userInfo != null)
228 lock (m_userProfilesByName)
229 {
230 if (m_userProfilesByName.ContainsKey(userInfo.UserProfile.Name))
241 { 231 {
242 m_userProfilesByName.Remove(userInfo.UserProfile.Name); 232 m_userProfilesByName.Remove(userInfo.UserProfile.Name);
233 return true;
243 } 234 }
244
245 return true;
246 } 235 }
247 }
248 236
249 return false; 237 return false;
250 } 238 }