* Add folders and items locking in external manipulations of InventoryFolderImpl carried out by CachedUserInfo

* These will do temporarily pending refactoring
0.6.0-stable
Justin Clarke Casey 2008-04-22 20:59:08 +00:00
parent 8d8b4a314f
commit cd29f90418
1 changed files with 35 additions and 20 deletions

View File

@ -142,6 +142,8 @@ namespace OpenSim.Framework.Communications.Cache
// "[INVENTORY CACHE]: Resolving pending received folder {0} {1} into {2} {3}", // "[INVENTORY CACHE]: Resolving pending received folder {0} {1} into {2} {3}",
// folder.name, folder.folderID, parent.name, parent.folderID); // folder.name, folder.folderID, parent.name, parent.folderID);
lock (parent.SubFolders)
{
if (!parent.SubFolders.ContainsKey(folder.ID)) if (!parent.SubFolders.ContainsKey(folder.ID))
{ {
parent.SubFolders.Add(folder.ID, folder); parent.SubFolders.Add(folder.ID, folder);
@ -149,6 +151,7 @@ namespace OpenSim.Framework.Communications.Cache
} }
} }
} }
}
/// <summary> /// <summary>
/// Callback invoked when the inventory is received from an async request to the inventory service /// Callback invoked when the inventory is received from an async request to the inventory service
@ -211,6 +214,8 @@ namespace OpenSim.Framework.Communications.Cache
} }
} }
else if (RootFolder.ID == folderInfo.ParentID) else if (RootFolder.ID == folderInfo.ParentID)
{
lock (RootFolder.SubFolders)
{ {
if (!RootFolder.SubFolders.ContainsKey(folderInfo.ID)) if (!RootFolder.SubFolders.ContainsKey(folderInfo.ID))
{ {
@ -221,9 +226,12 @@ namespace OpenSim.Framework.Communications.Cache
AddPendingFolder(folderInfo); AddPendingFolder(folderInfo);
} }
} }
}
else else
{ {
InventoryFolderImpl folder = RootFolder.HasSubFolder(folderInfo.ParentID); InventoryFolderImpl folder = RootFolder.HasSubFolder(folderInfo.ParentID);
lock (folder.SubFolders)
{
if (folder != null) if (folder != null)
{ {
if (!folder.SubFolders.ContainsKey(folderInfo.ID)) if (!folder.SubFolders.ContainsKey(folderInfo.ID))
@ -236,6 +244,7 @@ namespace OpenSim.Framework.Communications.Cache
AddPendingFolder(folderInfo); AddPendingFolder(folderInfo);
} }
} }
}
ResolvePendingFolders(folderInfo); ResolvePendingFolders(folderInfo);
} }
@ -258,16 +267,21 @@ namespace OpenSim.Framework.Communications.Cache
if ((userID == UserProfile.ID) && (RootFolder != null)) if ((userID == UserProfile.ID) && (RootFolder != null))
{ {
if (itemInfo.Folder == RootFolder.ID) if (itemInfo.Folder == RootFolder.ID)
{
lock (RootFolder.Items)
{ {
if (!RootFolder.Items.ContainsKey(itemInfo.ID)) if (!RootFolder.Items.ContainsKey(itemInfo.ID))
{ {
RootFolder.Items.Add(itemInfo.ID, itemInfo); RootFolder.Items.Add(itemInfo.ID, itemInfo);
} }
} }
}
else else
{ {
InventoryFolderImpl folder = RootFolder.HasSubFolder(itemInfo.Folder); InventoryFolderImpl folder = RootFolder.HasSubFolder(itemInfo.Folder);
if (folder != null) if (folder != null)
{
lock (folder.Items)
{ {
if (!folder.Items.ContainsKey(itemInfo.ID)) if (!folder.Items.ContainsKey(itemInfo.ID))
{ {
@ -277,6 +291,7 @@ namespace OpenSim.Framework.Communications.Cache
} }
} }
} }
}
/// <summary> /// <summary>
/// Add an item to the user's inventory /// Add an item to the user's inventory