diff options
author | Justin Clarke Casey | 2008-04-11 18:13:10 +0000 |
---|---|---|
committer | Justin Clarke Casey | 2008-04-11 18:13:10 +0000 |
commit | a5176c2e2c4d2791ec15a22db4309bb15bc3ae98 (patch) | |
tree | bbadbbd793ebda546831e9541e312d480d5dae0c /OpenSim/Framework/Communications/Cache | |
parent | * fix bug 935 (diff) | |
download | opensim-SC_OLD-a5176c2e2c4d2791ec15a22db4309bb15bc3ae98.zip opensim-SC_OLD-a5176c2e2c4d2791ec15a22db4309bb15bc3ae98.tar.gz opensim-SC_OLD-a5176c2e2c4d2791ec15a22db4309bb15bc3ae98.tar.bz2 opensim-SC_OLD-a5176c2e2c4d2791ec15a22db4309bb15bc3ae98.tar.xz |
* Change inventory async response deliver to deliver all items and folders at once, rather than each individual
* This is required in order to work towards eliminating some inventory race conditions and to better deal with situations where a grid inventory server is slow or not responding.
Diffstat (limited to 'OpenSim/Framework/Communications/Cache')
-rw-r--r-- | OpenSim/Framework/Communications/Cache/CachedUserInfo.cs | 109 | ||||
-rw-r--r-- | OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs | 16 |
2 files changed, 87 insertions, 38 deletions
diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 1208605..cf701cb 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs | |||
@@ -118,64 +118,82 @@ namespace OpenSim.Framework.Communications.Cache | |||
118 | } | 118 | } |
119 | } | 119 | } |
120 | } | 120 | } |
121 | 121 | ||
122 | /// <summary> | 122 | /// <summary> |
123 | /// Callback invoked when a folder is received from an async request to the inventory service. | 123 | /// Callback invoked when the inventory is received from an async request to the inventory service |
124 | /// </summary> | 124 | /// </summary> |
125 | /// <param name="userID"></param> | 125 | /// <param name="userID"></param> |
126 | /// <param name="folderInfo"></param> | 126 | /// <param name="inventoryCollection"></param> |
127 | public void FolderReceive(LLUUID userID, InventoryFolderImpl folderInfo) | 127 | public void InventoryReceive(LLUUID userID, ICollection<InventoryFolderImpl> folders, ICollection<InventoryItemBase> items) |
128 | { | 128 | { |
129 | // FIXME: Exceptions thrown upwards never appear on the console. Could fix further up if these | 129 | // FIXME: Exceptions thrown upwards never appear on the console. Could fix further up if these |
130 | // are simply being swallowed | 130 | // are simply being swallowed |
131 | try | 131 | try |
132 | { | ||
133 | foreach (InventoryFolderImpl folder in folders) | ||
134 | { | ||
135 | FolderReceive(userID, folder); | ||
136 | } | ||
137 | |||
138 | foreach (InventoryItemBase item in items) | ||
139 | { | ||
140 | ItemReceive(userID, item); | ||
141 | } | ||
142 | } | ||
143 | catch (Exception e) | ||
132 | { | 144 | { |
145 | m_log.ErrorFormat("[INVENTORY CACHE]: {0}", e); | ||
146 | } | ||
147 | } | ||
148 | |||
149 | /// <summary> | ||
150 | /// Callback invoked when a folder is received from an async request to the inventory service. | ||
151 | /// </summary> | ||
152 | /// <param name="userID"></param> | ||
153 | /// <param name="folderInfo"></param> | ||
154 | private void FolderReceive(LLUUID userID, InventoryFolderImpl folderInfo) | ||
155 | { | ||
133 | // m_log.DebugFormat( | 156 | // m_log.DebugFormat( |
134 | // "[INVENTORY CACHE]: Received folder {0} {1} for user {2}", | 157 | // "[INVENTORY CACHE]: Received folder {0} {1} for user {2}", |
135 | // folderInfo.name, folderInfo.folderID, userID); | 158 | // folderInfo.name, folderInfo.folderID, userID); |
136 | 159 | ||
137 | if (userID == UserProfile.ID) | 160 | if (userID == UserProfile.ID) |
161 | { | ||
162 | if (RootFolder == null) | ||
138 | { | 163 | { |
139 | if (RootFolder == null) | 164 | if (folderInfo.ParentID == LLUUID.Zero) |
140 | { | 165 | { |
141 | if (folderInfo.ParentID == LLUUID.Zero) | 166 | m_rootFolder = folderInfo; |
142 | { | ||
143 | m_rootFolder = folderInfo; | ||
144 | } | ||
145 | } | 167 | } |
146 | else if (RootFolder.ID == folderInfo.ParentID) | 168 | } |
169 | else if (RootFolder.ID == folderInfo.ParentID) | ||
170 | { | ||
171 | if (!RootFolder.SubFolders.ContainsKey(folderInfo.ID)) | ||
147 | { | 172 | { |
148 | if (!RootFolder.SubFolders.ContainsKey(folderInfo.ID)) | 173 | RootFolder.SubFolders.Add(folderInfo.ID, folderInfo); |
149 | { | ||
150 | RootFolder.SubFolders.Add(folderInfo.ID, folderInfo); | ||
151 | } | ||
152 | else | ||
153 | { | ||
154 | AddPendingFolder(folderInfo); | ||
155 | } | ||
156 | } | 174 | } |
157 | else | 175 | else |
158 | { | 176 | { |
159 | InventoryFolderImpl folder = RootFolder.HasSubFolder(folderInfo.ParentID); | 177 | AddPendingFolder(folderInfo); |
160 | if (folder != null) | 178 | } |
161 | { | 179 | } |
162 | if (!folder.SubFolders.ContainsKey(folderInfo.ID)) | 180 | else |
163 | { | 181 | { |
164 | folder.SubFolders.Add(folderInfo.ID, folderInfo); | 182 | InventoryFolderImpl folder = RootFolder.HasSubFolder(folderInfo.ParentID); |
165 | } | 183 | if (folder != null) |
166 | } | 184 | { |
167 | else | 185 | if (!folder.SubFolders.ContainsKey(folderInfo.ID)) |
168 | { | 186 | { |
169 | AddPendingFolder(folderInfo); | 187 | folder.SubFolders.Add(folderInfo.ID, folderInfo); |
170 | } | 188 | } |
171 | } | 189 | } |
172 | 190 | else | |
173 | ResolvePendingFolders(folderInfo); | 191 | { |
192 | AddPendingFolder(folderInfo); | ||
193 | } | ||
174 | } | 194 | } |
175 | } | 195 | |
176 | catch (Exception e) | 196 | ResolvePendingFolders(folderInfo); |
177 | { | ||
178 | m_log.ErrorFormat("[INVENTORY CACHE] {0}", e); | ||
179 | } | 197 | } |
180 | } | 198 | } |
181 | 199 | ||
@@ -187,7 +205,7 @@ namespace OpenSim.Framework.Communications.Cache | |||
187 | /// </summary> | 205 | /// </summary> |
188 | /// <param name="userID"></param> | 206 | /// <param name="userID"></param> |
189 | /// <param name="folderInfo"></param> | 207 | /// <param name="folderInfo"></param> |
190 | public void ItemReceive(LLUUID userID, InventoryItemBase itemInfo) | 208 | private void ItemReceive(LLUUID userID, InventoryItemBase itemInfo) |
191 | { | 209 | { |
192 | if ((userID == UserProfile.ID) && (RootFolder != null)) | 210 | if ((userID == UserProfile.ID) && (RootFolder != null)) |
193 | { | 211 | { |
@@ -212,6 +230,11 @@ namespace OpenSim.Framework.Communications.Cache | |||
212 | } | 230 | } |
213 | } | 231 | } |
214 | 232 | ||
233 | /// <summary> | ||
234 | /// Add an item to the user's inventory | ||
235 | /// </summary> | ||
236 | /// <param name="userID"></param> | ||
237 | /// <param name="itemInfo"></param> | ||
215 | public void AddItem(LLUUID userID, InventoryItemBase itemInfo) | 238 | public void AddItem(LLUUID userID, InventoryItemBase itemInfo) |
216 | { | 239 | { |
217 | if ((userID == UserProfile.ID) && HasInventory) | 240 | if ((userID == UserProfile.ID) && HasInventory) |
@@ -221,6 +244,11 @@ namespace OpenSim.Framework.Communications.Cache | |||
221 | } | 244 | } |
222 | } | 245 | } |
223 | 246 | ||
247 | /// <summary> | ||
248 | /// Update an item in the user's inventory | ||
249 | /// </summary> | ||
250 | /// <param name="userID"></param> | ||
251 | /// <param name="itemInfo"></param> | ||
224 | public void UpdateItem(LLUUID userID, InventoryItemBase itemInfo) | 252 | public void UpdateItem(LLUUID userID, InventoryItemBase itemInfo) |
225 | { | 253 | { |
226 | if ((userID == UserProfile.ID) && HasInventory) | 254 | if ((userID == UserProfile.ID) && HasInventory) |
@@ -229,6 +257,12 @@ namespace OpenSim.Framework.Communications.Cache | |||
229 | } | 257 | } |
230 | } | 258 | } |
231 | 259 | ||
260 | /// <summary> | ||
261 | /// Delete an item from the user's inventory | ||
262 | /// </summary> | ||
263 | /// <param name="userID"></param> | ||
264 | /// <param name="item"></param> | ||
265 | /// <returns></returns> | ||
232 | public bool DeleteItem(LLUUID userID, InventoryItemBase item) | 266 | public bool DeleteItem(LLUUID userID, InventoryItemBase item) |
233 | { | 267 | { |
234 | bool result = false; | 268 | bool result = false; |
@@ -240,6 +274,7 @@ namespace OpenSim.Framework.Communications.Cache | |||
240 | m_commsManager.InventoryService.DeleteInventoryItem(userID, item); | 274 | m_commsManager.InventoryService.DeleteInventoryItem(userID, item); |
241 | } | 275 | } |
242 | } | 276 | } |
277 | |||
243 | return result; | 278 | return result; |
244 | } | 279 | } |
245 | } | 280 | } |
diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index b924d5c..6b09e01 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs | |||
@@ -97,7 +97,7 @@ namespace OpenSim.Framework.Communications.Cache | |||
97 | CachedUserInfo userInfo = GetUserDetails(userID); | 97 | CachedUserInfo userInfo = GetUserDetails(userID); |
98 | if (userInfo != null) | 98 | if (userInfo != null) |
99 | { | 99 | { |
100 | m_commsManager.InventoryService.RequestInventoryForUser(userID, userInfo.FolderReceive, userInfo.ItemReceive); | 100 | m_commsManager.InventoryService.RequestInventoryForUser(userID, userInfo.InventoryReceive); |
101 | } | 101 | } |
102 | else | 102 | else |
103 | { | 103 | { |
@@ -118,6 +118,14 @@ namespace OpenSim.Framework.Communications.Cache | |||
118 | return null; | 118 | return null; |
119 | } | 119 | } |
120 | 120 | ||
121 | /// <summary> | ||
122 | /// Handle an inventory folder creation request from the client. | ||
123 | /// </summary> | ||
124 | /// <param name="remoteClient"></param> | ||
125 | /// <param name="folderID"></param> | ||
126 | /// <param name="folderType"></param> | ||
127 | /// <param name="folderName"></param> | ||
128 | /// <param name="parentID"></param> | ||
121 | public void HandleCreateInventoryFolder(IClientAPI remoteClient, LLUUID folderID, ushort folderType, | 129 | public void HandleCreateInventoryFolder(IClientAPI remoteClient, LLUUID folderID, ushort folderType, |
122 | string folderName, LLUUID parentID) | 130 | string folderName, LLUUID parentID) |
123 | { | 131 | { |
@@ -189,6 +197,12 @@ namespace OpenSim.Framework.Communications.Cache | |||
189 | } | 197 | } |
190 | } | 198 | } |
191 | 199 | ||
200 | /// <summary> | ||
201 | /// Handle an inventory folder move request from the client. | ||
202 | /// </summary> | ||
203 | /// <param name="remoteClient"></param> | ||
204 | /// <param name="folderID"></param> | ||
205 | /// <param name="parentID"></param> | ||
192 | public void HandleMoveInventoryFolder(IClientAPI remoteClient, LLUUID folderID, LLUUID parentID) | 206 | public void HandleMoveInventoryFolder(IClientAPI remoteClient, LLUUID folderID, LLUUID parentID) |
193 | { | 207 | { |
194 | CachedUserInfo userProfile; | 208 | CachedUserInfo userProfile; |