aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/Communications/Cache/CachedUserInfo.cs')
-rw-r--r--OpenSim/Framework/Communications/Cache/CachedUserInfo.cs62
1 files changed, 54 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}