* Various 1.19.0.5 grid inventory request fixes. These will only take affect once the region and the grid servers have upgraded to this revision

* You may also need to clear your cache before seeing any effect.
* These fixes may or may not affect inventory on the RC client.
* These fixes should make non-root folders work better, stop inventory failure on first login, allow trash to be emptied and make texture picker in object edit view work properly
* Fixes are 1) make initial root folder request wait for async inventory delivery, 2) deliver all folders in the initial login skeleton, not just the root child ones and 3) deal 
with situations where we receive child folders from the inventory service before their parent is received.
0.6.0-stable
Justin Clarke Casey 2008-03-29 22:18:44 +00:00
parent 0a9782494c
commit 875211b262
8 changed files with 203 additions and 55 deletions

View File

@ -25,6 +25,9 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
using System;
using System.Collections.Generic;
using libsecondlife; using libsecondlife;
namespace OpenSim.Framework.Communications.Cache namespace OpenSim.Framework.Communications.Cache
@ -35,19 +38,81 @@ namespace OpenSim.Framework.Communications.Cache
= log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private readonly CommunicationsManager m_parentCommsManager; private readonly CommunicationsManager m_parentCommsManager;
// Fields
// FIXME: These need to be hidden behind accessors
public InventoryFolderImpl RootFolder = null; public InventoryFolderImpl RootFolder = null;
public UserProfileData UserProfile = null; public UserProfileData UserProfile = null;
/// <summary>
/// Stores received folders for which we have not yet received the parents.
/// </summary></param>
private IDictionary<LLUUID, IList<InventoryFolderImpl>> pendingCategorizationFolders
= new Dictionary<LLUUID, IList<InventoryFolderImpl>>();
public CachedUserInfo(CommunicationsManager commsManager) public CachedUserInfo(CommunicationsManager commsManager)
{ {
m_parentCommsManager = commsManager; m_parentCommsManager = commsManager;
} }
// Methods /// <summary>
/// Store a folder pending categorization when its parent is received.
/// </summary>
/// <param name="folder"></param>
private void AddPendingFolder(InventoryFolderImpl folder)
{
LLUUID parentFolderId = folder.parentID;
if (pendingCategorizationFolders.ContainsKey(parentFolderId))
{
pendingCategorizationFolders[parentFolderId].Add(folder);
}
else
{
IList<InventoryFolderImpl> folders = new List<InventoryFolderImpl>();
folders.Add(folder);
pendingCategorizationFolders[parentFolderId] = folders;
}
}
/// <summary>
/// Add any pending folders which are children of parent
/// </summary>
/// <param name="parentId">
/// A <see cref="LLUUID"/>
/// </param>
private void ResolvePendingFolders(InventoryFolderImpl parent)
{
if (pendingCategorizationFolders.ContainsKey(parent.folderID))
{
foreach (InventoryFolderImpl folder in pendingCategorizationFolders[parent.folderID])
{
// m_log.DebugFormat(
// "[INVENTORY CACHE]: Resolving pending received folder {0} {1} into {2} {3}",
// folder.name, folder.folderID, parent.name, parent.folderID);
if (!parent.SubFolders.ContainsKey(folder.folderID))
{
parent.SubFolders.Add(folder.folderID, folder);
}
}
}
}
/// <summary>
/// Callback invoked when a folder is received from an async request to the inventory service.
/// </summary>
/// <param name="userID"></param>
/// <param name="folderInfo"></param>
public void FolderReceive(LLUUID userID, InventoryFolderImpl folderInfo) public void FolderReceive(LLUUID userID, InventoryFolderImpl folderInfo)
{ {
//m_log.DebugFormat("[INVENTORY CACHE]: Received folder {0} {1} for user {2}", folderInfo.name, folderInfo.folderID, userID); // FIXME: Exceptions thrown upwards never appear on the console. Could fix further up if these
// are simply being swallowed
try
{
// m_log.DebugFormat(
// "[INVENTORY CACHE]: Received folder {0} {1} for user {2}",
// folderInfo.name, folderInfo.folderID, userID);
if (userID == UserProfile.UUID) if (userID == UserProfile.UUID)
{ {
@ -64,6 +129,10 @@ namespace OpenSim.Framework.Communications.Cache
{ {
RootFolder.SubFolders.Add(folderInfo.folderID, folderInfo); RootFolder.SubFolders.Add(folderInfo.folderID, folderInfo);
} }
else
{
AddPendingFolder(folderInfo);
}
} }
else else
{ {
@ -75,10 +144,29 @@ namespace OpenSim.Framework.Communications.Cache
folder.SubFolders.Add(folderInfo.folderID, folderInfo); folder.SubFolders.Add(folderInfo.folderID, folderInfo);
} }
} }
} else
{
AddPendingFolder(folderInfo);
} }
} }
ResolvePendingFolders(folderInfo);
}
}
catch (Exception e)
{
m_log.ErrorFormat("[INVENTORY CACHE] {0}", e);
}
}
/// <summary>
/// Callback invoked when an item is received from an async request to the inventory service.
///
/// FIXME: We're assuming here that items are always received after all the folders have been
/// received.
/// </summary>
/// <param name="userID"></param>
/// <param name="folderInfo"></param>
public void ItemReceive(LLUUID userID, InventoryItemBase itemInfo) public void ItemReceive(LLUUID userID, InventoryItemBase itemInfo)
{ {
if ((userID == UserProfile.UUID) && (RootFolder != null)) if ((userID == UserProfile.UUID) && (RootFolder != null))

View File

@ -27,7 +27,10 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading;
using libsecondlife; using libsecondlife;
using OpenSim.Framework.Console; using OpenSim.Framework.Console;
namespace OpenSim.Framework.Communications.Cache namespace OpenSim.Framework.Communications.Cache
@ -65,9 +68,7 @@ namespace OpenSim.Framework.Communications.Cache
if (userInfo.UserProfile != null) if (userInfo.UserProfile != null)
{ {
// The request itself will occur when the agent finishes logging on to the region // The inventory will be populated when the user actually enters the scene
// so there's no need to do it here.
//RequestInventoryForUser(userID, userInfo);
m_userProfiles.Add(userID, userInfo); m_userProfiles.Add(userID, userInfo);
} }
else else
@ -219,10 +220,34 @@ namespace OpenSim.Framework.Communications.Cache
CachedUserInfo userProfile; CachedUserInfo userProfile;
if (m_userProfiles.TryGetValue(remoteClient.AgentId, out 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.
if (userProfile.RootFolder == null)
{
int attempts = 5;
while (attempts-- > 0)
{
Thread.Sleep(3000);
if (userProfile.RootFolder != null)
{
break;
}
}
}
if (userProfile.RootFolder != null) if (userProfile.RootFolder != null)
{ {
if (userProfile.RootFolder.folderID == folderID) if (userProfile.RootFolder.folderID == folderID)
{ {
// m_log.DebugFormat(
// "[AGENT INVENTORY]: Found root folder {0} for client {1}",
// folderID, remoteClient.AgentId);
remoteClient.SendInventoryFolderDetails( remoteClient.SendInventoryFolderDetails(
remoteClient.AgentId, folderID, userProfile.RootFolder.RequestListOfItems(), remoteClient.AgentId, folderID, userProfile.RootFolder.RequestListOfItems(),
userProfile.RootFolder.RequestListOfFolders(), userProfile.RootFolder.RequestListOfFolders(),
@ -234,6 +259,10 @@ namespace OpenSim.Framework.Communications.Cache
{ {
if ((fold = userProfile.RootFolder.HasSubFolder(folderID)) != null) if ((fold = userProfile.RootFolder.HasSubFolder(folderID)) != null)
{ {
// m_log.DebugFormat(
// "[AGENT INVENTORY]: Found folder {0} for client {1}",
// folderID, remoteClient.AgentId);
remoteClient.SendInventoryFolderDetails( remoteClient.SendInventoryFolderDetails(
remoteClient.AgentId, folderID, fold.RequestListOfItems(), remoteClient.AgentId, folderID, fold.RequestListOfItems(),
fold.RequestListOfFolders(), fetchFolders, fetchItems); fold.RequestListOfFolders(), fetchFolders, fetchItems);

View File

@ -76,13 +76,28 @@ namespace OpenSim.Framework.Communications
#region IInventoryServices methods #region IInventoryServices methods
// See IInventoryServices /// <summary>
/// Guid to UUID wrapper for same name IInventoryServices method
/// </summary>
/// <param name="rawUserID"></param>
/// <returns></returns>
public List<InventoryFolderBase> RequestFirstLevelFolders(Guid rawUserID) public List<InventoryFolderBase> RequestFirstLevelFolders(Guid rawUserID)
{ {
LLUUID userID = new LLUUID(rawUserID); LLUUID userID = new LLUUID(rawUserID);
return RequestFirstLevelFolders(userID); return RequestFirstLevelFolders(userID);
} }
/// <summary>
/// Guid to UUID wrapper for same name IInventoryServices method
/// </summary>
/// <param name="rawUserID"></param>
/// <returns></returns>
public List<InventoryFolderBase> GetInventorySkeleton(Guid rawUserID)
{
LLUUID userID = new LLUUID(rawUserID);
return GetInventorySkeleton(userID);
}
// See IInventoryServices // See IInventoryServices
public List<InventoryFolderBase> RequestFirstLevelFolders(LLUUID userID) public List<InventoryFolderBase> RequestFirstLevelFolders(LLUUID userID)
{ {
@ -112,7 +127,7 @@ namespace OpenSim.Framework.Communications
// See IInventoryServices // See IInventoryServices
public List<InventoryFolderBase> GetInventorySkeleton(LLUUID userId) public List<InventoryFolderBase> GetInventorySkeleton(LLUUID userId)
{ {
// m_log.DebugFormat("[AGENT INVENTORY]: Getting inventory skeleton for {0}", userId); m_log.DebugFormat("[AGENT INVENTORY]: Getting inventory skeleton for {0}", userId);
List<InventoryFolderBase> userFolders = new List<InventoryFolderBase>(); List<InventoryFolderBase> userFolders = new List<InventoryFolderBase>();

View File

@ -272,7 +272,7 @@ namespace OpenSim.Framework.UserManagement
} }
catch (Exception e) catch (Exception e)
{ {
m_log.Info("[LOGIN]: Login failed, exception" + e.ToString()); m_log.Info("[LOGIN]: Login failed, " + e.ToString());
} }
} }

View File

@ -108,8 +108,7 @@ namespace OpenSim.Grid.InventoryServer
{ {
LLUUID userID = new LLUUID(rawUserID); LLUUID userID = new LLUUID(rawUserID);
// We get enough verbose messages later on for diagnostics m_log.Info("[GRID INVENTORY]: Request for inventory of " + userID.ToString());
//m_log.Info("[INVENTORY]: Request for inventory for " + userID.ToString());
InventoryCollection invCollection = new InventoryCollection(); InventoryCollection invCollection = new InventoryCollection();
List<InventoryFolderBase> folders; List<InventoryFolderBase> folders;
@ -120,6 +119,21 @@ namespace OpenSim.Grid.InventoryServer
invCollection.Folders = folders; invCollection.Folders = folders;
invCollection.UserID = userID; invCollection.UserID = userID;
} }
// foreach (InventoryFolderBase folder in folders)
// {
// m_log.DebugFormat(
// "[GRID INVENTORY]: Sending back folder {0}, {1}",
// folder.name, folder.folderID);
// }
//
// foreach (InventoryItemBase item in allItems)
// {
// m_log.DebugFormat(
// "[GRID INVENTORY]: Sending back item {0}, {1}, folder {2}",
// item.inventoryName, item.inventoryID, item.parentFolderID);
// }
return invCollection; return invCollection;
} }

View File

@ -83,29 +83,32 @@ namespace OpenSim.Grid.InventoryServer
protected void AddHttpHandlers() protected void AddHttpHandlers()
{ {
m_httpServer.AddStreamHandler( m_httpServer.AddStreamHandler(
new RestDeserialisehandler<Guid, InventoryCollection>("POST", "/GetInventory/", new RestDeserialisehandler<Guid, InventoryCollection>(
m_inventoryService.GetUserInventory)); "POST", "/GetInventory/", m_inventoryService.GetUserInventory));
m_httpServer.AddStreamHandler(
new RestDeserialisehandler<Guid, bool>("POST", "/CreateInventory/",
m_inventoryService.CreateUsersInventory));
m_httpServer.AddStreamHandler(
new RestDeserialisehandler<InventoryFolderBase, bool>("POST", "/NewFolder/",
m_inventoryService.AddInventoryFolder));
m_httpServer.AddStreamHandler( m_httpServer.AddStreamHandler(
new RestDeserialisehandler<InventoryFolderBase, bool>("POST", "/MoveFolder/", new RestDeserialisehandler<Guid, bool>(
m_inventoryService.MoveInventoryFolder)); "POST", "/CreateInventory/", m_inventoryService.CreateUsersInventory));
m_httpServer.AddStreamHandler( m_httpServer.AddStreamHandler(
new RestDeserialisehandler<InventoryItemBase, bool>("POST", "/NewItem/", new RestDeserialisehandler<InventoryFolderBase, bool>(
m_inventoryService.AddInventoryItem)); "POST", "/NewFolder/", m_inventoryService.AddInventoryFolder));
m_httpServer.AddStreamHandler(
new RestDeserialisehandler<InventoryItemBase, bool>("POST", "/DeleteItem/",
m_inventoryService.DeleteInvItem));
m_httpServer.AddStreamHandler( m_httpServer.AddStreamHandler(
new RestDeserialisehandler<Guid, List<InventoryFolderBase>>("POST", "/RootFolders/", new RestDeserialisehandler<InventoryFolderBase, bool>(
m_inventoryService.RequestFirstLevelFolders)); "POST", "/MoveFolder/", m_inventoryService.MoveInventoryFolder));
m_httpServer.AddStreamHandler(
new RestDeserialisehandler<InventoryItemBase, bool>(
"POST", "/NewItem/", m_inventoryService.AddInventoryItem));
m_httpServer.AddStreamHandler(
new RestDeserialisehandler<InventoryItemBase, bool>(
"POST", "/DeleteItem/", m_inventoryService.DeleteInvItem));
m_httpServer.AddStreamHandler(
new RestDeserialisehandler<Guid, List<InventoryFolderBase>>
("POST", "/RootFolders/", m_inventoryService.GetInventorySkeleton));
// httpServer.AddStreamHandler(new InventoryManager.GetInventory(m_inventoryManager)); // httpServer.AddStreamHandler(new InventoryManager.GetInventory(m_inventoryManager));
} }

View File

@ -323,6 +323,8 @@ namespace OpenSim.Grid.UserServer
Hashtable TempHash; Hashtable TempHash;
foreach (InventoryFolderBase InvFolder in folders) foreach (InventoryFolderBase InvFolder in folders)
{ {
// m_log.DebugFormat("[LOGIN]: Received agent inventory folder {0}", InvFolder.name);
if (InvFolder.parentID == LLUUID.Zero) if (InvFolder.parentID == LLUUID.Zero)
{ {
rootID = InvFolder.folderID; rootID = InvFolder.folderID;

View File

@ -1149,9 +1149,6 @@ namespace OpenSim.Region.ClientStack
List<InventoryFolderBase> folders, List<InventoryFolderBase> folders,
bool fetchFolders, bool fetchItems) bool fetchFolders, bool fetchItems)
{ {
// XXX Very temporarily, always fetch the folders
fetchFolders = true;
// An inventory descendents packet consists of a single agent section and an inventory details // An inventory descendents packet consists of a single agent section and an inventory details
// section for each inventory item. The size of each inventory item is approximately 550 bytes. // section for each inventory item. The size of each inventory item is approximately 550 bytes.
// In theory, UDP has a maximum packet size of 64k, so it should be possible to send descendent // In theory, UDP has a maximum packet size of 64k, so it should be possible to send descendent