Fix potential concurrency issue since the LSL notecard cache was not being checked for expiry under lock

user_profiles
Justin Clark-Casey (justincc) 2013-02-28 21:19:23 +00:00
parent a523ed1e4d
commit 239a8da74e
1 changed files with 10 additions and 7 deletions

View File

@ -11689,7 +11689,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public static void Cache(UUID assetID, string text) public static void Cache(UUID assetID, string text)
{ {
CacheCheck(); CheckCache();
lock (m_Notecards) lock (m_Notecards)
{ {
@ -11774,13 +11774,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return line; 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]; foreach (UUID key in new List<UUID>(m_Notecards.Keys))
if (nc.lastRef.AddSeconds(30) < DateTime.Now) {
m_Notecards.Remove(key); Notecard nc = m_Notecards[key];
if (nc.lastRef.AddSeconds(30) < DateTime.Now)
m_Notecards.Remove(key);
}
} }
} }
} }