aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared
diff options
context:
space:
mode:
authorMelanie2012-08-01 00:08:02 +0100
committerMelanie2012-08-01 00:08:02 +0100
commit8114260946be8bbe6754d497f104804d203e00e2 (patch)
treeb87ac81a06f7fffbb39d88e6bc24d4c615b05cee /OpenSim/Region/ScriptEngine/Shared
parentMerge branch 'avination' into careminster (diff)
parentResolve a deadlock between INPCModule and SensorRepeat by replacing the Senso... (diff)
downloadopensim-SC-8114260946be8bbe6754d497f104804d203e00e2.zip
opensim-SC-8114260946be8bbe6754d497f104804d203e00e2.tar.gz
opensim-SC-8114260946be8bbe6754d497f104804d203e00e2.tar.bz2
opensim-SC-8114260946be8bbe6754d497f104804d203e00e2.tar.xz
Merge branch 'master' into careminster
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs78
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs39
2 files changed, 80 insertions, 37 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
index 19f3ce1..f6c8e38 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
@@ -51,8 +51,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
51 { 51 {
52 get 52 get
53 { 53 {
54 lock (SenseRepeatListLock) 54 return SenseRepeaters.Count;
55 return SenseRepeaters.Count;
56 } 55 }
57 } 56 }
58 57
@@ -115,6 +114,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
115 public double distance; 114 public double distance;
116 } 115 }
117 116
117 /// <summary>
118 /// Sensors to process.
119 /// </summary>
120 /// <remarks>
121 /// Do not add or remove sensors from this list directly. Instead, copy the list and substitute the updated
122 /// copy. This is to avoid locking the list for the duration of the sensor sweep, which increases the danger
123 /// of deadlocks with future code updates.
124 ///
125 /// Always lock SenseRepeatListLock when updating this list.
126 /// </remarks>
118 private List<SenseRepeatClass> SenseRepeaters = new List<SenseRepeatClass>(); 127 private List<SenseRepeatClass> SenseRepeaters = new List<SenseRepeatClass>();
119 private object SenseRepeatListLock = new object(); 128 private object SenseRepeatListLock = new object();
120 129
@@ -124,6 +133,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
124 { 133 {
125 // Always remove first, in case this is a re-set 134 // Always remove first, in case this is a re-set
126 UnSetSenseRepeaterEvents(m_localID, m_itemID); 135 UnSetSenseRepeaterEvents(m_localID, m_itemID);
136
127 if (sec == 0) // Disabling timer 137 if (sec == 0) // Disabling timer
128 return; 138 return;
129 139
@@ -143,9 +153,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
143 ts.host = host; 153 ts.host = host;
144 154
145 ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval); 155 ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval);
156
157 AddSenseRepeater(ts);
158 }
159
160 private void AddSenseRepeater(SenseRepeatClass senseRepeater)
161 {
146 lock (SenseRepeatListLock) 162 lock (SenseRepeatListLock)
147 { 163 {
148 SenseRepeaters.Add(ts); 164 List<SenseRepeatClass> newSenseRepeaters = new List<SenseRepeatClass>(SenseRepeaters);
165 newSenseRepeaters.Add(senseRepeater);
166 SenseRepeaters = newSenseRepeaters;
149 } 167 }
150 } 168 }
151 169
@@ -154,39 +172,32 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
154 // Remove from timer 172 // Remove from timer
155 lock (SenseRepeatListLock) 173 lock (SenseRepeatListLock)
156 { 174 {
157 List<SenseRepeatClass> NewSensors = new List<SenseRepeatClass>(); 175 List<SenseRepeatClass> newSenseRepeaters = new List<SenseRepeatClass>();
158 foreach (SenseRepeatClass ts in SenseRepeaters) 176 foreach (SenseRepeatClass ts in SenseRepeaters)
159 { 177 {
160 if (ts.localID != m_localID || ts.itemID != m_itemID) 178 if (ts.localID != m_localID || ts.itemID != m_itemID)
161 { 179 {
162 NewSensors.Add(ts); 180 newSenseRepeaters.Add(ts);
163 } 181 }
164 } 182 }
165 SenseRepeaters.Clear(); 183
166 SenseRepeaters = NewSensors; 184 SenseRepeaters = newSenseRepeaters;
167 } 185 }
168 } 186 }
169 187
170 public void CheckSenseRepeaterEvents() 188 public void CheckSenseRepeaterEvents()
171 { 189 {
172 lock (SenseRepeatListLock) 190 // Go through all timers
191 foreach (SenseRepeatClass ts in SenseRepeaters)
173 { 192 {
174 // Nothing to do here? 193 // Time has passed?
175 if (SenseRepeaters.Count == 0) 194 if (ts.next.ToUniversalTime() < DateTime.Now.ToUniversalTime())
176 return;
177
178 // Go through all timers
179 foreach (SenseRepeatClass ts in SenseRepeaters)
180 { 195 {
181 // Time has passed? 196 SensorSweep(ts);
182 if (ts.next.ToUniversalTime() < DateTime.Now.ToUniversalTime()) 197 // set next interval
183 { 198 ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval);
184 SensorSweep(ts);
185 // set next interval
186 ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval);
187 }
188 } 199 }
189 } // lock 200 }
190 } 201 }
191 202
192 public void SenseOnce(uint m_localID, UUID m_itemID, 203 public void SenseOnce(uint m_localID, UUID m_itemID,
@@ -619,21 +630,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
619 { 630 {
620 List<Object> data = new List<Object>(); 631 List<Object> data = new List<Object>();
621 632
622 lock (SenseRepeatListLock) 633 foreach (SenseRepeatClass ts in SenseRepeaters)
623 { 634 {
624 foreach (SenseRepeatClass ts in SenseRepeaters) 635 if (ts.itemID == itemID)
625 { 636 {
626 if (ts.itemID == itemID) 637 data.Add(ts.interval);
627 { 638 data.Add(ts.name);
628 data.Add(ts.interval); 639 data.Add(ts.keyID);
629 data.Add(ts.name); 640 data.Add(ts.type);
630 data.Add(ts.keyID); 641 data.Add(ts.range);
631 data.Add(ts.type); 642 data.Add(ts.arc);
632 data.Add(ts.range);
633 data.Add(ts.arc);
634 }
635 } 643 }
636 } 644 }
645
637 return data.ToArray(); 646 return data.ToArray();
638 } 647 }
639 648
@@ -667,8 +676,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
667 ts.next = 676 ts.next =
668 DateTime.Now.ToUniversalTime().AddSeconds(ts.interval); 677 DateTime.Now.ToUniversalTime().AddSeconds(ts.interval);
669 678
670 lock (SenseRepeatListLock) 679 AddSenseRepeater(ts);
671 SenseRepeaters.Add(ts);
672 680
673 idx += 6; 681 idx += 6;
674 } 682 }
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs
index b24f016..97dd0f6 100644
--- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs
@@ -38,7 +38,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
38{ 38{
39 public class CSCodeGenerator : ICodeConverter 39 public class CSCodeGenerator : ICodeConverter
40 { 40 {
41// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 41// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
42 42
43 private SYMBOL m_astRoot = null; 43 private SYMBOL m_astRoot = null;
44 private Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> m_positionMap; 44 private Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> m_positionMap;
@@ -255,7 +255,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
255 else if (s is IdentDotExpression) 255 else if (s is IdentDotExpression)
256 retstr += Generate(CheckName(((IdentDotExpression) s).Name) + "." + ((IdentDotExpression) s).Member, s); 256 retstr += Generate(CheckName(((IdentDotExpression) s).Name) + "." + ((IdentDotExpression) s).Member, s);
257 else if (s is IdentExpression) 257 else if (s is IdentExpression)
258 retstr += Generate(CheckName(((IdentExpression) s).Name), s); 258 retstr += GenerateIdentifier(((IdentExpression) s).Name, s);
259 else if (s is IDENT) 259 else if (s is IDENT)
260 retstr += Generate(CheckName(((TOKEN) s).yytext), s); 260 retstr += Generate(CheckName(((TOKEN) s).yytext), s);
261 else 261 else
@@ -868,6 +868,41 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
868 } 868 }
869 869
870 /// <summary> 870 /// <summary>
871 /// Generates the code for an identifier
872 /// </summary>
873 /// <param name="id">The symbol name</param>
874 /// <param name="s">The Symbol node.</param>
875 /// <returns>String containing C# code for identifier reference.</returns>
876 private string GenerateIdentifier(string id, SYMBOL s)
877 {
878 if (m_comms != null)
879 {
880 object value = m_comms.LookupModConstant(id);
881 if (value != null)
882 {
883 string retval = null;
884 if (value is int)
885 retval = ((int)value).ToString();
886 else if (value is float)
887 retval = String.Format("new LSL_Types.LSLFloat({0})",((float)value).ToString());
888 else if (value is string)
889 retval = String.Format("new LSL_Types.LSLString(\"{0}\")",((string)value));
890 else if (value is OpenMetaverse.UUID)
891 retval = String.Format("new LSL_Types.key(\"{0}\")",((OpenMetaverse.UUID)value).ToString());
892 else if (value is OpenMetaverse.Vector3)
893 retval = String.Format("new LSL_Types.Vector3(\"{0}\")",((OpenMetaverse.Vector3)value).ToString());
894 else if (value is OpenMetaverse.Quaternion)
895 retval = String.Format("new LSL_Types.Quaternion(\"{0}\")",((OpenMetaverse.Quaternion)value).ToString());
896 else retval = id;
897
898 return Generate(retval, s);
899 }
900 }
901
902 return Generate(CheckName(id), s);
903 }
904
905 /// <summary>
871 /// Generates the code for a FunctionCall node. 906 /// Generates the code for a FunctionCall node.
872 /// </summary> 907 /// </summary>
873 /// <param name="fc">The FunctionCall node.</param> 908 /// <param name="fc">The FunctionCall node.</param>