aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Communications/Cache
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/Communications/Cache')
-rw-r--r--OpenSim/Framework/Communications/Cache/CachedUserInfo.cs62
-rw-r--r--OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs36
2 files changed, 90 insertions, 8 deletions
diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs
index a245af1..3d7ada3 100644
--- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs
+++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs
@@ -45,25 +45,31 @@ namespace OpenSim.Framework.Communications.Cache
45 /// The comms manager holds references to services (user, grid, inventory, etc.) 45 /// The comms manager holds references to services (user, grid, inventory, etc.)
46 /// </summary> 46 /// </summary>
47 private readonly CommunicationsManager m_commsManager; 47 private readonly CommunicationsManager m_commsManager;
48 48
49 private UserProfileData m_userProfile;
50 public UserProfileData UserProfile { get { return m_userProfile; } } 49 public UserProfileData UserProfile { get { return m_userProfile; } }
50 private UserProfileData m_userProfile;
51 51
52 52 /// <summary>
53 /// Has we received the user's inventory from the inventory service?
54 /// </summary>
53 private bool m_hasInventory; 55 private bool m_hasInventory;
54 56
55 /// <summary> 57 /// <summary>
58 /// Inventory requests waiting for receipt of this user's inventory from the inventory service.
59 /// </summary>
60 private readonly IList<IInventoryRequest> m_pendingRequests = new List<IInventoryRequest>();
61
62 /// <summary>
56 /// Has this user info object yet received its inventory information from the invetnroy service? 63 /// Has this user info object yet received its inventory information from the invetnroy service?
57 /// </summary> 64 /// </summary>
58 public bool HasInventory { get { return m_hasInventory; } } 65 public bool HasInventory { get { return m_hasInventory; } }
59 66
60 // FIXME: These need to be hidden behind accessors
61 private InventoryFolderImpl m_rootFolder; 67 private InventoryFolderImpl m_rootFolder;
62 public InventoryFolderImpl RootFolder { get { return m_rootFolder; } } 68 public InventoryFolderImpl RootFolder { get { return m_rootFolder; } }
63 69
64 /// <summary> 70 /// <summary>
65 /// Stores received folders for which we have not yet received the parents. 71 /// FIXME: This could be contained within a local variable - it doesn't need to be a field
66 /// </summary></param> 72 /// </summary>
67 private IDictionary<LLUUID, IList<InventoryFolderImpl>> pendingCategorizationFolders 73 private IDictionary<LLUUID, IList<InventoryFolderImpl>> pendingCategorizationFolders
68 = new Dictionary<LLUUID, IList<InventoryFolderImpl>>(); 74 = new Dictionary<LLUUID, IList<InventoryFolderImpl>>();
69 75
@@ -79,6 +85,27 @@ namespace OpenSim.Framework.Communications.Cache
79 } 85 }
80 86
81 /// <summary> 87 /// <summary>
88 /// This allows a request to be added to be processed once we receive a user's inventory
89 /// from the inventory service. If we already have the inventory, the request
90 /// is executed immediately instead.
91 /// </summary>
92 /// <param name="parent"></param>
93 public void AddRequest(IInventoryRequest request)
94 {
95 lock (m_pendingRequests)
96 {
97 if (m_hasInventory)
98 {
99 request.Execute();
100 }
101 else
102 {
103 m_pendingRequests.Add(request);
104 }
105 }
106 }
107
108 /// <summary>
82 /// Store a folder pending categorization when its parent is received. 109 /// Store a folder pending categorization when its parent is received.
83 /// </summary> 110 /// </summary>
84 /// <param name="folder"></param> 111 /// <param name="folder"></param>
@@ -148,8 +175,19 @@ namespace OpenSim.Framework.Communications.Cache
148 { 175 {
149 m_log.ErrorFormat("[INVENTORY CACHE]: Error processing inventory received from inventory service, {0}", e); 176 m_log.ErrorFormat("[INVENTORY CACHE]: Error processing inventory received from inventory service, {0}", e);
150 } 177 }
151 178
152 m_hasInventory = true; 179 // Deal with pending requests
180 lock (m_pendingRequests)
181 {
182 // We're going to change inventory status within the lock to avoid a race condition
183 // where requests are processed after the AddRequest() method has been called.
184 m_hasInventory = true;
185
186 foreach (IInventoryRequest request in m_pendingRequests)
187 {
188 request.Execute();
189 }
190 }
153 } 191 }
154 192
155 /// <summary> 193 /// <summary>
@@ -288,4 +326,12 @@ namespace OpenSim.Framework.Communications.Cache
288 return result; 326 return result;
289 } 327 }
290 } 328 }
329
330 /// <summary>
331 /// Should be implemented by callers which require a callback when the user's inventory is received
332 /// </summary>
333 public interface IInventoryRequest
334 {
335 void Execute();
336 }
291} 337}
diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs
index bf8ff40..cbf2ded 100644
--- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs
+++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs
@@ -201,6 +201,9 @@ namespace OpenSim.Framework.Communications.Cache
201 public void HandleUpdateInventoryFolder(IClientAPI remoteClient, LLUUID folderID, ushort type, string name, 201 public void HandleUpdateInventoryFolder(IClientAPI remoteClient, LLUUID folderID, ushort type, string name,
202 LLUUID parentID) 202 LLUUID parentID)
203 { 203 {
204// m_log.DebugFormat(
205// "[AGENT INVENTORY] Updating inventory folder {0} {1} for {2} {3}", folderID, name, remoteClient.Name, remoteClient.AgentId);
206
204 CachedUserInfo userProfile; 207 CachedUserInfo userProfile;
205 208
206 if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile)) 209 if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile))
@@ -216,6 +219,10 @@ namespace OpenSim.Framework.Communications.Cache
216 baseFolder.Version = userProfile.RootFolder.Version; 219 baseFolder.Version = userProfile.RootFolder.Version;
217 m_commsManager.InventoryService.AddNewInventoryFolder(remoteClient.AgentId, baseFolder); 220 m_commsManager.InventoryService.AddNewInventoryFolder(remoteClient.AgentId, baseFolder);
218 } 221 }
222 else
223 {
224 userProfile.AddRequest(new UpdateFolderRequest(this, remoteClient, folderID, type, name, parentID));
225 }
219 } 226 }
220 } 227 }
221 228
@@ -492,4 +499,33 @@ namespace OpenSim.Framework.Communications.Cache
492 } 499 }
493 } 500 }
494 } 501 }
502
503 /// <summary>
504 /// Used to create an update folder request if we haven't yet received the user's inventory
505 /// </summary>
506 internal class UpdateFolderRequest : IInventoryRequest
507 {
508 private UserProfileCacheService m_userProfileCacheService;
509 private IClientAPI m_client;
510 private LLUUID m_folderID;
511 private ushort m_type;
512 private string m_name;
513 private LLUUID m_parentID;
514
515 internal UpdateFolderRequest(
516 UserProfileCacheService cacheService, IClientAPI client, LLUUID folderID, ushort type, string name, LLUUID parentID)
517 {
518 m_userProfileCacheService = cacheService;
519 m_client = client;
520 m_folderID = folderID;
521 m_type = type;
522 m_name = name;
523 m_parentID = parentID;
524 }
525
526 public void Execute()
527 {
528 m_userProfileCacheService.HandleUpdateInventoryFolder(m_client, m_folderID, m_type, m_name, m_parentID);
529 }
530 }
495} 531}