diff options
author | Melanie | 2009-10-07 01:45:49 +0100 |
---|---|---|
committer | Melanie | 2009-10-07 01:45:49 +0100 |
commit | 89d23a1fa23cb191e7ebde047311adcadf3b2e45 (patch) | |
tree | 461ef0fdd6640a17db5b3d989f0e02b1cf40252e /OpenSim/Framework/Communications | |
parent | Rewrote parts of the code that were double-locking different objects. This is... (diff) | |
download | opensim-SC-89d23a1fa23cb191e7ebde047311adcadf3b2e45.zip opensim-SC-89d23a1fa23cb191e7ebde047311adcadf3b2e45.tar.gz opensim-SC-89d23a1fa23cb191e7ebde047311adcadf3b2e45.tar.bz2 opensim-SC-89d23a1fa23cb191e7ebde047311adcadf3b2e45.tar.xz |
Revert "Rewrote parts of the code that were double-locking different objects. This is about half of the code base reviewed."
This reverts commit e992ca025571a891333a57012c2cd4419b6581e5.
Diffstat (limited to 'OpenSim/Framework/Communications')
-rw-r--r-- | OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs | 66 |
1 files changed, 39 insertions, 27 deletions
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 | |||
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; | ||
132 | lock (m_userProfilesByName) | 131 | lock (m_userProfilesByName) |
133 | { | 132 | { |
133 | CachedUserInfo userInfo; | ||
134 | |||
134 | if (m_userProfilesByName.TryGetValue(string.Format(NAME_FORMAT, fname, lname), out userInfo)) | 135 | if (m_userProfilesByName.TryGetValue(string.Format(NAME_FORMAT, fname, lname), out userInfo)) |
136 | { | ||
135 | return userInfo; | 137 | 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 | } | ||
136 | } | 148 | } |
137 | UserProfileData userProfile = m_commsManager.UserService.GetUserProfile(fname, lname); | ||
138 | |||
139 | if (userProfile != null) | ||
140 | return AddToCaches(userProfile); | ||
141 | else | ||
142 | return null; | ||
143 | } | 149 | } |
144 | 150 | ||
145 | /// <summary> | 151 | /// <summary> |
@@ -154,14 +160,20 @@ namespace OpenSim.Framework.Communications.Cache | |||
154 | return null; | 160 | return null; |
155 | 161 | ||
156 | lock (m_userProfilesById) | 162 | lock (m_userProfilesById) |
163 | { | ||
157 | if (m_userProfilesById.ContainsKey(userID)) | 164 | if (m_userProfilesById.ContainsKey(userID)) |
165 | { | ||
158 | return m_userProfilesById[userID]; | 166 | return m_userProfilesById[userID]; |
159 | 167 | } | |
160 | UserProfileData userProfile = m_commsManager.UserService.GetUserProfile(userID); | 168 | else |
161 | if (userProfile != null) | 169 | { |
162 | return AddToCaches(userProfile); | 170 | UserProfileData userProfile = m_commsManager.UserService.GetUserProfile(userID); |
163 | else | 171 | if (userProfile != null) |
164 | return null; | 172 | return AddToCaches(userProfile); |
173 | else | ||
174 | return null; | ||
175 | } | ||
176 | } | ||
165 | } | 177 | } |
166 | 178 | ||
167 | /// <summary> | 179 | /// <summary> |
@@ -199,10 +211,14 @@ namespace OpenSim.Framework.Communications.Cache | |||
199 | CachedUserInfo createdUserInfo = new CachedUserInfo(m_InventoryService, userProfile); | 211 | CachedUserInfo createdUserInfo = new CachedUserInfo(m_InventoryService, userProfile); |
200 | 212 | ||
201 | lock (m_userProfilesById) | 213 | lock (m_userProfilesById) |
214 | { | ||
202 | m_userProfilesById[createdUserInfo.UserProfile.ID] = createdUserInfo; | 215 | m_userProfilesById[createdUserInfo.UserProfile.ID] = createdUserInfo; |
203 | 216 | ||
204 | lock (m_userProfilesByName) | 217 | lock (m_userProfilesByName) |
205 | m_userProfilesByName[createdUserInfo.UserProfile.Name] = createdUserInfo; | 218 | { |
219 | m_userProfilesByName[createdUserInfo.UserProfile.Name] = createdUserInfo; | ||
220 | } | ||
221 | } | ||
206 | 222 | ||
207 | return createdUserInfo; | 223 | return createdUserInfo; |
208 | } | 224 | } |
@@ -214,25 +230,21 @@ namespace OpenSim.Framework.Communications.Cache | |||
214 | /// <returns>true if there was a profile to remove, false otherwise</returns> | 230 | /// <returns>true if there was a profile to remove, false otherwise</returns> |
215 | protected bool RemoveFromCaches(UUID userId) | 231 | protected bool RemoveFromCaches(UUID userId) |
216 | { | 232 | { |
217 | CachedUserInfo userInfo = null; | ||
218 | lock (m_userProfilesById) | 233 | lock (m_userProfilesById) |
219 | { | 234 | { |
220 | if (m_userProfilesById.ContainsKey(userId)) | 235 | if (m_userProfilesById.ContainsKey(userId)) |
221 | { | 236 | { |
222 | userInfo = m_userProfilesById[userId]; | 237 | CachedUserInfo userInfo = m_userProfilesById[userId]; |
223 | m_userProfilesById.Remove(userId); | 238 | m_userProfilesById.Remove(userId); |
224 | } | 239 | |
225 | } | 240 | lock (m_userProfilesByName) |
226 | |||
227 | if (userInfo != null) | ||
228 | lock (m_userProfilesByName) | ||
229 | { | ||
230 | if (m_userProfilesByName.ContainsKey(userInfo.UserProfile.Name)) | ||
231 | { | 241 | { |
232 | m_userProfilesByName.Remove(userInfo.UserProfile.Name); | 242 | m_userProfilesByName.Remove(userInfo.UserProfile.Name); |
233 | return true; | ||
234 | } | 243 | } |
244 | |||
245 | return true; | ||
235 | } | 246 | } |
247 | } | ||
236 | 248 | ||
237 | return false; | 249 | return false; |
238 | } | 250 | } |