From 239a8da74e87bb22bb9107a0341829ff99bbd3fe Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Thu, 28 Feb 2013 21:19:23 +0000
Subject: Fix potential concurrency issue since the LSL notecard cache was not
 being checked for expiry under lock

---
 .../ScriptEngine/Shared/Api/Implementation/LSL_Api.cs   | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

(limited to 'OpenSim')

diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index ec24dc2..ab087af 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -11689,7 +11689,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
 
         public static void Cache(UUID assetID, string text)
         {
-            CacheCheck();
+            CheckCache();
 
             lock (m_Notecards)
             {
@@ -11774,14 +11774,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
             return line;
         }
 
-        public static void CacheCheck()
+        public static void CheckCache()
         {
-            foreach (UUID key in new List<UUID>(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<UUID>(m_Notecards.Keys))
+                {
+                    Notecard nc = m_Notecards[key];
+                    if (nc.lastRef.AddSeconds(30) < DateTime.Now)
+                        m_Notecards.Remove(key);
+                }
             }
         }
     }
-}
+}
\ No newline at end of file
-- 
cgit v1.1