Fix a timer list locking issue causing XMREngine deadlocks

avinationmerge
Melanie 2009-12-30 00:27:01 +01:00
parent 8ad8bd6282
commit 06f639b8f3
1 changed files with 17 additions and 15 deletions

View File

@ -109,25 +109,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
if (Timers.Count == 0)
return;
Dictionary<string, TimerClass>.ValueCollection tvals;
lock (TimerListLock)
{
// Go through all timers
Dictionary<string, TimerClass>.ValueCollection tvals = Timers.Values;
foreach (TimerClass ts in tvals)
{
// Time has passed?
if (ts.next < DateTime.Now.Ticks)
{
//m_log.Debug("Time has passed: Now: " + DateTime.Now.Ticks + ", Passed: " + ts.next);
// Add it to queue
m_CmdManager.m_ScriptEngine.PostScriptEvent(ts.itemID,
new EventParams("timer", new Object[0],
new DetectParams[0]));
// set next interval
tvals = Timers.Values;
}
//ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval);
ts.next = DateTime.Now.Ticks + ts.interval;
}
foreach (TimerClass ts in tvals)
{
// Time has passed?
if (ts.next < DateTime.Now.Ticks)
{
//m_log.Debug("Time has passed: Now: " + DateTime.Now.Ticks + ", Passed: " + ts.next);
// Add it to queue
m_CmdManager.m_ScriptEngine.PostScriptEvent(ts.itemID,
new EventParams("timer", new Object[0],
new DetectParams[0]));
// set next interval
//ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval);
ts.next = DateTime.Now.Ticks + ts.interval;
}
}
}