Inconsistent locking of SenseRepeaters in Script Engine.

When I attempt to 'save oar' on a region with thousands of scripts with timers, I get a NullReferenceException every time. The problem comes from inconsistent locking in SensorRepeat.cs of the SenseRepeaters List. It is iterated and modified in many places and these places are all wrapped in a lock except in the GetSerializationData(). This is the function throwing the exception because an item in the list becomes null during iteration.

The attached patch locks SenseRepeatListLock in GetSerializationData()
0.6.8-post-fixes
unknown 2009-10-23 03:52:49 -07:00 committed by Melanie
parent b0923e0d73
commit 71c929137f
1 changed files with 11 additions and 8 deletions

View File

@ -516,16 +516,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
{
List<Object> data = new List<Object>();
foreach (SenseRepeatClass ts in SenseRepeaters)
lock (SenseRepeatListLock)
{
if (ts.itemID == itemID)
foreach (SenseRepeatClass ts in SenseRepeaters)
{
data.Add(ts.interval);
data.Add(ts.name);
data.Add(ts.keyID);
data.Add(ts.type);
data.Add(ts.range);
data.Add(ts.arc);
if (ts.itemID == itemID)
{
data.Add(ts.interval);
data.Add(ts.name);
data.Add(ts.keyID);
data.Add(ts.type);
data.Add(ts.range);
data.Add(ts.arc);
}
}
}
return data.ToArray();