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 | |
parent | * fix bug 935 (diff) | |
download | opensim-SC-a5176c2e2c4d2791ec15a22db4309bb15bc3ae98.zip opensim-SC-a5176c2e2c4d2791ec15a22db4309bb15bc3ae98.tar.gz opensim-SC-a5176c2e2c4d2791ec15a22db4309bb15bc3ae98.tar.bz2 opensim-SC-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')
5 files changed, 109 insertions, 43 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; |
diff --git a/OpenSim/Framework/Communications/IInventoryServices.cs b/OpenSim/Framework/Communications/IInventoryServices.cs index ecc6c71..40e7ffd 100644 --- a/OpenSim/Framework/Communications/IInventoryServices.cs +++ b/OpenSim/Framework/Communications/IInventoryServices.cs | |||
@@ -26,21 +26,34 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System.Collections.Generic; | 28 | using System.Collections.Generic; |
29 | |||
29 | using libsecondlife; | 30 | using libsecondlife; |
31 | |||
30 | using OpenSim.Framework.Communications.Cache; | 32 | using OpenSim.Framework.Communications.Cache; |
31 | 33 | ||
32 | namespace OpenSim.Framework.Communications | 34 | namespace OpenSim.Framework.Communications |
33 | { | 35 | { |
34 | public delegate void InventoryFolderInfo(LLUUID userID, InventoryFolderImpl folderInfo); | 36 | /// <summary> |
37 | /// Callback used when a user's inventory is received from the inventory service | ||
38 | /// </summary> | ||
39 | public delegate void InventoryReceiptCallback(LLUUID userId, ICollection<InventoryFolderImpl> folders, ICollection<InventoryItemBase> items); | ||
40 | |||
41 | //public delegate void InventoryFolderInfo(LLUUID userID, InventoryFolderImpl folderInfo); | ||
35 | 42 | ||
36 | public delegate void InventoryItemInfo(LLUUID userID, InventoryItemBase itemInfo); | 43 | //public delegate void InventoryItemInfo(LLUUID userID, InventoryItemBase itemInfo); |
37 | 44 | ||
38 | /// <summary> | 45 | /// <summary> |
39 | /// Defines all the operations one can perform on a user's inventory. | 46 | /// Defines all the operations one can perform on a user's inventory. |
40 | /// </summary> | 47 | /// </summary> |
41 | public interface IInventoryServices | 48 | public interface IInventoryServices |
42 | { | 49 | { |
43 | void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, InventoryItemInfo itemCallBack); | 50 | /// <summary> |
51 | /// Request the inventory for a user. This is an asynchronous operation that will call the callback when the | ||
52 | /// inventory has been received | ||
53 | /// </summary> | ||
54 | /// <param name="userID"></param> | ||
55 | /// <param name="callback"></param> | ||
56 | void RequestInventoryForUser(LLUUID userID, InventoryReceiptCallback callback); | ||
44 | 57 | ||
45 | /// <summary> | 58 | /// <summary> |
46 | /// Add a new folder to the given user's inventory | 59 | /// Add a new folder to the given user's inventory |
diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index e50e19e..aedf4b3 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs | |||
@@ -158,8 +158,9 @@ namespace OpenSim.Framework.Communications | |||
158 | return false; | 158 | return false; |
159 | } | 159 | } |
160 | 160 | ||
161 | public abstract void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, | 161 | // See IInventoryServices |
162 | InventoryItemInfo itemCallBack); | 162 | public abstract void RequestInventoryForUser(LLUUID userID, InventoryReceiptCallback callback); |
163 | |||
163 | public abstract void AddNewInventoryFolder(LLUUID userID, InventoryFolderBase folder); | 164 | public abstract void AddNewInventoryFolder(LLUUID userID, InventoryFolderBase folder); |
164 | public abstract void MoveExistingInventoryFolder(InventoryFolderBase folder); | 165 | public abstract void MoveExistingInventoryFolder(InventoryFolderBase folder); |
165 | public abstract void AddNewInventoryItem(LLUUID userID, InventoryItemBase item); | 166 | public abstract void AddNewInventoryItem(LLUUID userID, InventoryItemBase item); |
diff --git a/OpenSim/Framework/InventoryCollection.cs b/OpenSim/Framework/InventoryCollection.cs index c8d8716..e76e1a9 100644 --- a/OpenSim/Framework/InventoryCollection.cs +++ b/OpenSim/Framework/InventoryCollection.cs | |||
@@ -32,6 +32,9 @@ using libsecondlife; | |||
32 | 32 | ||
33 | namespace OpenSim.Framework | 33 | namespace OpenSim.Framework |
34 | { | 34 | { |
35 | /// <summary> | ||
36 | /// Used to serialize a whole inventory for transfer over the network. | ||
37 | /// </summary> | ||
35 | public class InventoryCollection | 38 | public class InventoryCollection |
36 | { | 39 | { |
37 | public List<InventoryFolderBase> _folders; | 40 | public List<InventoryFolderBase> _folders; |