From d1147136946daf14724183b3191119be44ff8b16 Mon Sep 17 00:00:00 2001 From: CasperW Date: Tue, 24 Nov 2009 18:02:12 +0100 Subject: Drop all locking of part.TaskInventory in favour of a ReaderWriterLockSlim lock handler. This gives us: - Faster prim inventory actions. Multiple threads can read at once. - Fixes the known prim inventory thread locks - In the event of a thread lock occurring, it will usually self heal after sixty seconds with an error message in the console --- .../ScriptEngine/Shared/Instance/ScriptInstance.cs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared/Instance') diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index 063d50f..0f4a9ad 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs @@ -238,13 +238,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance if (part != null) { - lock (part.TaskInventory) + part.TaskInventory.LockItemsForRead(true); + if (part.TaskInventory.ContainsKey(m_ItemID)) { - if (part.TaskInventory.ContainsKey(m_ItemID)) - { - m_thisScriptTask = part.TaskInventory[m_ItemID]; - } + m_thisScriptTask = part.TaskInventory[m_ItemID]; } + part.TaskInventory.LockItemsForRead(false); } ApiManager am = new ApiManager(); @@ -429,14 +428,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance { int permsMask; UUID permsGranter; - lock (part.TaskInventory) + part.TaskInventory.LockItemsForRead(true); + if (!part.TaskInventory.ContainsKey(m_ItemID)) { - if (!part.TaskInventory.ContainsKey(m_ItemID)) - return; - - permsGranter = part.TaskInventory[m_ItemID].PermsGranter; - permsMask = part.TaskInventory[m_ItemID].PermsMask; + part.TaskInventory.LockItemsForRead(false); + return; } + permsGranter = part.TaskInventory[m_ItemID].PermsGranter; + permsMask = part.TaskInventory[m_ItemID].PermsMask; + part.TaskInventory.LockItemsForRead(false); if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) { -- cgit v1.1