From cd29f90418b8690cffc2df8fae52fa976090e574 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Tue, 22 Apr 2008 20:59:08 +0000 Subject: * Add folders and items locking in external manipulations of InventoryFolderImpl carried out by CachedUserInfo * These will do temporarily pending refactoring --- .../Communications/Cache/CachedUserInfo.cs | 55 ++++++++++++++-------- 1 file changed, 35 insertions(+), 20 deletions(-) diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 9a7ce42..f1268d5 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -142,10 +142,13 @@ namespace OpenSim.Framework.Communications.Cache // "[INVENTORY CACHE]: Resolving pending received folder {0} {1} into {2} {3}", // folder.name, folder.folderID, parent.name, parent.folderID); - if (!parent.SubFolders.ContainsKey(folder.ID)) + lock (parent.SubFolders) { - parent.SubFolders.Add(folder.ID, folder); - } + if (!parent.SubFolders.ContainsKey(folder.ID)) + { + parent.SubFolders.Add(folder.ID, folder); + } + } } } } @@ -212,28 +215,34 @@ namespace OpenSim.Framework.Communications.Cache } else if (RootFolder.ID == folderInfo.ParentID) { - if (!RootFolder.SubFolders.ContainsKey(folderInfo.ID)) + lock (RootFolder.SubFolders) { - RootFolder.SubFolders.Add(folderInfo.ID, folderInfo); + if (!RootFolder.SubFolders.ContainsKey(folderInfo.ID)) + { + RootFolder.SubFolders.Add(folderInfo.ID, folderInfo); + } + else + { + AddPendingFolder(folderInfo); + } } - else - { - AddPendingFolder(folderInfo); - } } else { InventoryFolderImpl folder = RootFolder.HasSubFolder(folderInfo.ParentID); - if (folder != null) + lock (folder.SubFolders) { - if (!folder.SubFolders.ContainsKey(folderInfo.ID)) + if (folder != null) { - folder.SubFolders.Add(folderInfo.ID, folderInfo); + if (!folder.SubFolders.ContainsKey(folderInfo.ID)) + { + folder.SubFolders.Add(folderInfo.ID, folderInfo); + } + } + else + { + AddPendingFolder(folderInfo); } - } - else - { - AddPendingFolder(folderInfo); } } @@ -259,9 +268,12 @@ namespace OpenSim.Framework.Communications.Cache { if (itemInfo.Folder == RootFolder.ID) { - if (!RootFolder.Items.ContainsKey(itemInfo.ID)) + lock (RootFolder.Items) { - RootFolder.Items.Add(itemInfo.ID, itemInfo); + if (!RootFolder.Items.ContainsKey(itemInfo.ID)) + { + RootFolder.Items.Add(itemInfo.ID, itemInfo); + } } } else @@ -269,9 +281,12 @@ namespace OpenSim.Framework.Communications.Cache InventoryFolderImpl folder = RootFolder.HasSubFolder(itemInfo.Folder); if (folder != null) { - if (!folder.Items.ContainsKey(itemInfo.ID)) + lock (folder.Items) { - folder.Items.Add(itemInfo.ID, itemInfo); + if (!folder.Items.ContainsKey(itemInfo.ID)) + { + folder.Items.Add(itemInfo.ID, itemInfo); + } } } } -- cgit v1.1