From 71c929137f48a0a7d97dbc866cbe2b12319aa40b Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 23 Oct 2009 03:52:49 -0700 Subject: 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() --- .../Shared/Api/Implementation/Plugins/SensorRepeat.cs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/ScriptEngine') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs index ee01c3c..b75a2e4 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs @@ -516,16 +516,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins { List data = new List(); - 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(); -- cgit v1.1