From 7ac7f79f88f51504680a24f1621115c595492f62 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 11 Apr 2008 18:46:54 +0000 Subject: [PATCH] * Eliminate a class of errors where an inventory request could be made before the region had completely received the inventory for the user. * A much larger race condition where the inventory request could be made before the region gets any data at all will also be fixed in the near future. * This change also fixes a regression from two patches ago where items stopped appearing in standalone inventory --- .../Communications/Cache/CachedUserInfo.cs | 31 ++++++++++++------- .../Local/LocalInventoryService.cs | 11 +++++-- .../OGS1/OGS1InventoryService.cs | 3 +- 3 files changed, 31 insertions(+), 14 deletions(-) diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index d97cf01f01..686f8d22d6 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -47,10 +47,18 @@ namespace OpenSim.Framework.Communications.Cache private UserProfileData m_userProfile; public UserProfileData UserProfile { get { return m_userProfile; } } + + + private bool m_hasInventory; + + /// + /// Has this user info object yet received its inventory information from the invetnroy service? + /// + public bool HasInventory { get { return m_hasInventory; } } // FIXME: These need to be hidden behind accessors private InventoryFolderImpl m_rootFolder; - public InventoryFolderImpl RootFolder { get { return m_rootFolder; } } + public InventoryFolderImpl RootFolder { get { return m_rootFolder; } } /// /// Stores received folders for which we have not yet received the parents. @@ -68,11 +76,6 @@ namespace OpenSim.Framework.Communications.Cache m_commsManager = commsManager; m_userProfile = userProfile; } - - /// - /// Has this user info object yet received its inventory information from the invetnroy service? - /// - public bool HasInventory { get { return RootFolder != null; } } /// /// Store a folder pending categorization when its parent is received. @@ -142,8 +145,10 @@ namespace OpenSim.Framework.Communications.Cache } catch (Exception e) { - m_log.ErrorFormat("[INVENTORY CACHE]: {0}", e); - } + m_log.ErrorFormat("[INVENTORY CACHE]: Error processing inventory received from inventory service, {0}", e); + } + + m_hasInventory = true; } /// @@ -153,9 +158,9 @@ namespace OpenSim.Framework.Communications.Cache /// private void FolderReceive(LLUUID userID, InventoryFolderImpl folderInfo) { -// m_log.DebugFormat( -// "[INVENTORY CACHE]: Received folder {0} {1} for user {2}", -// folderInfo.name, folderInfo.folderID, userID); + m_log.DebugFormat( + "[INVENTORY CACHE]: Received folder {0} {1} for user {2}", + folderInfo.Name, folderInfo.ID, userID); if (userID == UserProfile.ID) { @@ -207,6 +212,10 @@ namespace OpenSim.Framework.Communications.Cache /// private void ItemReceive(LLUUID userID, InventoryItemBase itemInfo) { + m_log.DebugFormat( + "[INVENTORY CACHE]: Received item {0} {1} for user {2}", + itemInfo.Name, itemInfo.ID, userID); + if ((userID == UserProfile.ID) && (RootFolder != null)) { if (itemInfo.Folder == RootFolder.ID) diff --git a/OpenSim/Region/Communications/Local/LocalInventoryService.cs b/OpenSim/Region/Communications/Local/LocalInventoryService.cs index e81a39f740..dafd6374fd 100644 --- a/OpenSim/Region/Communications/Local/LocalInventoryService.cs +++ b/OpenSim/Region/Communications/Local/LocalInventoryService.cs @@ -39,13 +39,18 @@ namespace OpenSim.Region.Communications.Local /// public class LocalInventoryService : InventoryServiceBase { + private static readonly log4net.ILog m_log + = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + public override void RequestInventoryForUser(LLUUID userID, InventoryReceiptCallback callback) { + m_log.InfoFormat("[LOCAL INVENTORY SERVICE]: Requesting inventory for user {0}", userID); + List skeletonFolders = GetInventorySkeleton(userID); InventoryFolderImpl rootFolder = null; - ICollection folders = new List(); - ICollection items = new List(); + List folders = new List(); + List items = new List(); // Need to retrieve the root folder on the first pass foreach (InventoryFolderBase folder in skeletonFolders) @@ -54,6 +59,7 @@ namespace OpenSim.Region.Communications.Local { rootFolder = new InventoryFolderImpl(folder); folders.Add(rootFolder); + items.AddRange(RequestFolderItems(rootFolder.ID)); } } @@ -64,6 +70,7 @@ namespace OpenSim.Region.Communications.Local if (folder.ID != rootFolder.ID) { folders.Add(new InventoryFolderImpl(folder)); + items.AddRange(RequestFolderItems(folder.ID)); } } } diff --git a/OpenSim/Region/Communications/OGS1/OGS1InventoryService.cs b/OpenSim/Region/Communications/OGS1/OGS1InventoryService.cs index dc26ce24de..8f293f98c0 100644 --- a/OpenSim/Region/Communications/OGS1/OGS1InventoryService.cs +++ b/OpenSim/Region/Communications/OGS1/OGS1InventoryService.cs @@ -38,7 +38,8 @@ namespace OpenSim.Region.Communications.OGS1 { public class OGS1InventoryService : IInventoryServices { - private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private static readonly log4net.ILog m_log + = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private string _inventoryServerUrl; private Dictionary m_RequestingInventory = new Dictionary();