Taking a reference to the value collection is not thread safe. Change this

to create a shallow copy instead and then iterate it's values to avoid the
"out of sync" error.
avinationmerge
Melanie Thielker 2015-03-23 22:15:25 +01:00
parent b5ac2eb1e1
commit 97ff01a0c2
1 changed files with 3 additions and 3 deletions

View File

@ -123,14 +123,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
if (Timers.Count == 0) if (Timers.Count == 0)
return; return;
Dictionary<string, TimerInfo>.ValueCollection tvals; Dictionary<string, TimerInfo> tvals;
lock (TimerListLock) lock (TimerListLock)
{ {
// Go through all timers // Go through all timers
tvals = Timers.Values; tvals = new Dictionary<string, TimerInfo>(Timers);
} }
foreach (TimerInfo ts in tvals) foreach (TimerInfo ts in tvals.Values)
{ {
// Time has passed? // Time has passed?
if (ts.next < DateTime.Now.Ticks) if (ts.next < DateTime.Now.Ticks)