* Consistently lock part.TaskInventory as pointed out in http://opensimulator.org/mantis/view.php?id=3159

* Not locking causes enumeration exceptions as described in this matis
* part.TaskInventory needs to be locked for every access as it's a dictionary
* Extra locking will hopefully not cause any major issues - in places where the enumeration of the dictionary performs other lock or long running operations, the dictionary is 
cloned instead
This commit is contained in:
Justin Clarke Casey
2009-02-20 14:04:29 +00:00
parent c28b2f799a
commit 01f70de2ea
7 changed files with 417 additions and 204 deletions

View File

@@ -1710,12 +1710,15 @@ if (m_shape != null) {
info.AddValue("m_inventoryFileName", Inventory.GetInventoryFileName());
info.AddValue("m_folderID", UUID);
info.AddValue("PhysActor", PhysActor);
Dictionary<Guid, TaskInventoryItem> TaskInventory_work = new Dictionary<Guid, TaskInventoryItem>();
foreach (UUID id in TaskInventory.Keys)
lock (TaskInventory)
{
TaskInventory_work.Add(id.Guid, TaskInventory[id]);
foreach (UUID id in TaskInventory.Keys)
{
TaskInventory_work.Add(id.Guid, TaskInventory[id]);
}
}
info.AddValue("TaskInventory", TaskInventory_work);
@@ -2166,13 +2169,16 @@ if (m_shape != null) {
{
//Trys to fetch sound id from prim's inventory.
//Prim's inventory doesn't support non script items yet
SceneObjectPart op = this;
foreach (KeyValuePair<UUID, TaskInventoryItem> item in op.TaskInventory)
lock (TaskInventory)
{
if (item.Value.Name == sound)
foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory)
{
soundID = item.Value.ItemID;
break;
if (item.Value.Name == sound)
{
soundID = item.Value.ItemID;
break;
}
}
}
}
@@ -2486,13 +2492,15 @@ if (m_shape != null) {
if (!UUID.TryParse(sound, out soundID))
{
// search sound file from inventory
SceneObjectPart op = this;
foreach (KeyValuePair<UUID, TaskInventoryItem> item in op.TaskInventory)
lock (TaskInventory)
{
if (item.Value.Name == sound && item.Value.Type == (int)AssetType.Sound)
foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory)
{
soundID = item.Value.ItemID;
break;
if (item.Value.Name == sound && item.Value.Type == (int)AssetType.Sound)
{
soundID = item.Value.ItemID;
break;
}
}
}
}