From 3f345bf685a80189c8a33ec1514c356064a6fa70 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 9 May 2008 21:33:19 +0000 Subject: * Removing polling delay for non-CAPS inventory fetch if the client has not yet received data from the inventory service * Replaced instead with the system now used by other requests where the fetch request is placed on a queue and service when the data comes in --- .../Communications/Cache/CachedUserInfo.cs | 51 +++++++++++++++++- .../Cache/UserProfileCacheService.cs | 62 ++-------------------- .../Grid/InventoryServer/GridInventoryService.cs | 5 +- 3 files changed, 58 insertions(+), 60 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 03ba1db..218fd5a 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -42,7 +42,10 @@ namespace OpenSim.Framework.Communications.Cache internal delegate void CreateFolderDelegate(string folderName, LLUUID folderID, ushort folderType, LLUUID parentID); internal delegate void MoveFolderDelegate(LLUUID folderID, LLUUID parentID); internal delegate void PurgeFolderDelegate(LLUUID folderID); - internal delegate void UpdateFolderDelegate(string name, LLUUID folderID, ushort type, LLUUID parentID); + internal delegate void UpdateFolderDelegate(string name, LLUUID folderID, ushort type, LLUUID parentID); + + internal delegate void SendInventoryDescendentsDelegate( + IClientAPI client, LLUUID folderID, bool fetchFolders, bool fetchItems); /// /// Stores user profile and inventory data received from backend services for a particular user. @@ -557,6 +560,52 @@ namespace OpenSim.Framework.Communications.Cache return false; } + + /// + /// Send details of the inventory items and/or folders in a given folder to the client. + /// + /// + /// + /// + /// + /// true if the request was queued or successfully processed, false otherwise + public bool SendInventoryDecendents(IClientAPI client, LLUUID folderID, bool fetchFolders, bool fetchItems) + { + if (HasInventory) + { + InventoryFolderImpl folder; + + if ((folder = RootFolder.FindFolder(folderID)) != null) + { +// m_log.DebugFormat( +// "[AGENT INVENTORY]: Found folder {0} for client {1}", +// folderID, remoteClient.AgentId); + + client.SendInventoryFolderDetails( + client.AgentId, folderID, folder.RequestListOfItems(), + folder.RequestListOfFolders(), fetchFolders, fetchItems); + + return true; + } + else + { + m_log.WarnFormat( + "[AGENT INVENTORY]: Could not find folder {0} requested by user {1} {2}", + folderID, client.Name, client.AgentId); + + return false; + } + } + else + { + AddRequest( + new InventoryRequest( + Delegate.CreateDelegate(typeof(SendInventoryDescendentsDelegate), this, "SendInventoryDecendents"), + new object[] { client, folderID, fetchFolders, fetchItems })); + + return true; + } + } } /// diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index b167682..7f911dc 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -247,7 +247,7 @@ namespace OpenSim.Framework.Communications.Cache public void HandleFetchInventoryDescendents(IClientAPI remoteClient, LLUUID folderID, LLUUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder) { - // XXX We're not handling sortOrder yet! + // FIXME MAYBE: We're not handling sortOrder! InventoryFolderImpl fold = null; if ((fold = libraryRoot.FindFolder(folderID)) != null) @@ -262,68 +262,14 @@ namespace OpenSim.Framework.Communications.Cache CachedUserInfo userProfile; if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile)) { - // XXX: When a client crosses into a scene, their entire inventory is fetched - // asynchronously. However, if the client is logging on and does not have a cached root - // folder, then the root folder request usually comes in *before* the async completes, leading to - // inventory failure. - // - // This is a crude way of dealing with that by retrying the lookup. - //BUG: This should be replaced with a async event. - if (!userProfile.HasInventory) - { - int attempts = 5; - while (attempts-- > 0) - { - Thread.Sleep(2000); - - if (userProfile.HasInventory) - { - break; - } - } - } - - if (userProfile.HasInventory) - { - if ((fold = userProfile.RootFolder.FindFolder(folderID)) != null) - { -// m_log.DebugFormat( -// "[AGENT INVENTORY]: Found folder {0} for client {1}", -// folderID, remoteClient.AgentId); - - remoteClient.SendInventoryFolderDetails( - remoteClient.AgentId, folderID, fold.RequestListOfItems(), - fold.RequestListOfFolders(), fetchFolders, fetchItems); - - return; - } - else - { - m_log.WarnFormat( - "[AGENT INVENTORY]: Could not find folder {0} requested by user {1} {2}", - folderID, remoteClient.Name, remoteClient.AgentId); - } - } - else - { - m_log.ErrorFormat("[AGENT INVENTORY]: Could not find root folder for user {0}", remoteClient.Name); - - return; - } + userProfile.SendInventoryDecendents(remoteClient, folderID, fetchFolders, fetchItems); } else { m_log.ErrorFormat( "[AGENT INVENTORY]: Could not find user profile for {0} {1}", remoteClient.Name, remoteClient.AgentId); - - return; - } - - // If we've reached this point then we couldn't find the folder, even though the client thinks - // it exists - m_log.ErrorFormat("[AGENT INVENTORY]: Could not find folder {0} for user {1}", - folderID, remoteClient.Name); + } } /// @@ -345,7 +291,7 @@ namespace OpenSim.Framework.Communications.Cache // "[INVENTORY CACHE]: Fetching folders ({0}), items ({1}) from {2} for agent {3}", // fetchFolders, fetchItems, folderID, agentID); - // XXX We're not handling sortOrder yet! + // FIXME MAYBE: We're not handling sortOrder! InventoryFolderImpl fold; if ((fold = libraryRoot.FindFolder(folderID)) != null) diff --git a/OpenSim/Grid/InventoryServer/GridInventoryService.cs b/OpenSim/Grid/InventoryServer/GridInventoryService.cs index 2ba215b..80f0c5e 100644 --- a/OpenSim/Grid/InventoryServer/GridInventoryService.cs +++ b/OpenSim/Grid/InventoryServer/GridInventoryService.cs @@ -56,10 +56,13 @@ namespace OpenSim.Grid.InventoryServer /// /// The user's inventory. If an inventory cannot be found then an empty collection is returned. public InventoryCollection GetUserInventory(Guid rawUserID) - { + { LLUUID userID = new LLUUID(rawUserID); m_log.InfoFormat("[GRID AGENT INVENTORY]: Processing request for inventory of {0}", userID); + + // Uncomment me to simulate a slow responding inventory server + //Thread.Sleep(16000); InventoryCollection invCollection = new InventoryCollection(); -- cgit v1.1