From f8a57edb2c5a81c7a9fce40942475ff05e929db9 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Thu, 28 Feb 2013 21:19:23 +0000 Subject: [PATCH] Fix potential concurrency issue since the LSL notecard cache was not being checked for expiry under lock --- .../Shared/Api/Implementation/LSL_Api.cs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 325fae7f79..2830bd8488 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -11347,7 +11347,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public static void Cache(UUID assetID, string text) { - CacheCheck(); + CheckCache(); lock (m_Notecards) { @@ -11432,13 +11432,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return line; } - public static void CacheCheck() + public static void CheckCache() { - foreach (UUID key in new List(m_Notecards.Keys)) + lock (m_Notecards) { - Notecard nc = m_Notecards[key]; - if (nc.lastRef.AddSeconds(30) < DateTime.Now) - m_Notecards.Remove(key); + foreach (UUID key in new List(m_Notecards.Keys)) + { + Notecard nc = m_Notecards[key]; + if (nc.lastRef.AddSeconds(30) < DateTime.Now) + m_Notecards.Remove(key); + } } } }