diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/XMREngine/XMRInstRun.cs')
-rw-r--r-- | OpenSim/Region/ScriptEngine/XMREngine/XMRInstRun.cs | 85 |
1 files changed, 45 insertions, 40 deletions
diff --git a/OpenSim/Region/ScriptEngine/XMREngine/XMRInstRun.cs b/OpenSim/Region/ScriptEngine/XMREngine/XMRInstRun.cs index 61ae549..9654b01 100644 --- a/OpenSim/Region/ScriptEngine/XMREngine/XMRInstRun.cs +++ b/OpenSim/Region/ScriptEngine/XMREngine/XMRInstRun.cs | |||
@@ -27,14 +27,7 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Threading; | 29 | using System.Threading; |
30 | using System.Reflection; | ||
31 | using System.Collections; | ||
32 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
33 | using System.Reflection.Emit; | ||
34 | using System.Runtime.Remoting.Lifetime; | ||
35 | using System.Security.Policy; | ||
36 | using System.IO; | ||
37 | using System.Xml; | ||
38 | using System.Text; | 31 | using System.Text; |
39 | using OpenMetaverse; | 32 | using OpenMetaverse; |
40 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
@@ -140,22 +133,23 @@ namespace OpenSim.Region.ScriptEngine.XMREngine | |||
140 | * of all others so the m_DetachQuantum won't run out | 133 | * of all others so the m_DetachQuantum won't run out |
141 | * before attach(NULL_KEY) is executed. | 134 | * before attach(NULL_KEY) is executed. |
142 | */ | 135 | */ |
143 | case ScriptEventCode.attach: { | 136 | case ScriptEventCode.attach: |
137 | { | ||
144 | if (evt.Params[0].ToString() == UUID.Zero.ToString()) | 138 | if (evt.Params[0].ToString() == UUID.Zero.ToString()) |
145 | { | 139 | { |
146 | LinkedListNode<EventParams> lln2 = null; | 140 | LinkedListNode<EventParams> lln2 = null; |
147 | for (lln2 = m_EventQueue.First; lln2 != null; lln2 = lln2.Next) { | 141 | for (lln2 = m_EventQueue.First; lln2 != null; lln2 = lln2.Next) |
142 | { | ||
148 | EventParams evt2 = lln2.Value; | 143 | EventParams evt2 = lln2.Value; |
149 | ScriptEventCode evc2 = (ScriptEventCode)Enum.Parse (typeof (ScriptEventCode), | 144 | ScriptEventCode evc2 = (ScriptEventCode)Enum.Parse (typeof (ScriptEventCode), |
150 | evt2.EventName); | 145 | evt2.EventName); |
151 | if ((evc2 != ScriptEventCode.state_entry) && | 146 | if ((evc2 != ScriptEventCode.state_entry) && |
152 | (evc2 != ScriptEventCode.attach)) break; | 147 | (evc2 != ScriptEventCode.attach)) break; |
153 | } | 148 | } |
154 | if (lln2 == null) { | 149 | if (lln2 == null) |
155 | m_EventQueue.AddLast(lln); | 150 | m_EventQueue.AddLast(lln); |
156 | } else { | 151 | else |
157 | m_EventQueue.AddBefore(lln2, lln); | 152 | m_EventQueue.AddBefore(lln2, lln); |
158 | } | ||
159 | /* If we're detaching, limit the qantum. This will also | 153 | /* If we're detaching, limit the qantum. This will also |
160 | * cause the script to self-suspend after running this | 154 | * cause the script to self-suspend after running this |
161 | * event | 155 | * event |
@@ -165,16 +159,15 @@ namespace OpenSim.Region.ScriptEngine.XMREngine | |||
165 | m_DetachQuantum = 100; | 159 | m_DetachQuantum = 100; |
166 | } | 160 | } |
167 | else | 161 | else |
168 | { | ||
169 | m_EventQueue.AddLast(lln); | 162 | m_EventQueue.AddLast(lln); |
170 | } | ||
171 | break; | 163 | break; |
172 | } | 164 | } |
173 | 165 | ||
174 | /* | 166 | /* |
175 | * All others just go on end in the order queued. | 167 | * All others just go on end in the order queued. |
176 | */ | 168 | */ |
177 | default: { | 169 | default: |
170 | { | ||
178 | m_EventQueue.AddLast(lln); | 171 | m_EventQueue.AddLast(lln); |
179 | break; | 172 | break; |
180 | } | 173 | } |
@@ -187,7 +180,8 @@ namespace OpenSim.Region.ScriptEngine.XMREngine | |||
187 | * to do the same thing right now. | 180 | * to do the same thing right now. |
188 | * Dont' flag it if it's still suspended! | 181 | * Dont' flag it if it's still suspended! |
189 | */ | 182 | */ |
190 | if ((m_IState == XMRInstState.IDLE) && !m_Suspended) { | 183 | if ((m_IState == XMRInstState.IDLE) && !m_Suspended) |
184 | { | ||
191 | m_IState = XMRInstState.ONSTARTQ; | 185 | m_IState = XMRInstState.ONSTARTQ; |
192 | startIt = true; | 186 | startIt = true; |
193 | } | 187 | } |
@@ -196,11 +190,13 @@ namespace OpenSim.Region.ScriptEngine.XMREngine | |||
196 | * If instance is sleeping (ie, possibly in xmrEventDequeue), | 190 | * If instance is sleeping (ie, possibly in xmrEventDequeue), |
197 | * wake it up if event is in the mask. | 191 | * wake it up if event is in the mask. |
198 | */ | 192 | */ |
199 | if ((m_SleepUntil > DateTime.UtcNow) && !m_Suspended) { | 193 | if ((m_SleepUntil > DateTime.UtcNow) && !m_Suspended) |
194 | { | ||
200 | int evc1 = (int)evc; | 195 | int evc1 = (int)evc; |
201 | int evc2 = evc1 - 32; | 196 | int evc2 = evc1 - 32; |
202 | if ((((uint)evc1 < (uint)32) && (((m_SleepEventMask1 >> evc1) & 1) != 0)) || | 197 | if ((((uint)evc1 < (uint)32) && (((m_SleepEventMask1 >> evc1) & 1) != 0)) || |
203 | (((uint)evc2 < (uint)32) && (((m_SleepEventMask2 >> evc2) & 1) != 0))) { | 198 | (((uint)evc2 < (uint)32) && (((m_SleepEventMask2 >> evc2) & 1) != 0))) |
199 | { | ||
204 | wakeIt = true; | 200 | wakeIt = true; |
205 | } | 201 | } |
206 | } | 202 | } |
@@ -210,14 +206,14 @@ namespace OpenSim.Region.ScriptEngine.XMREngine | |||
210 | * If transitioned from IDLE->ONSTARTQ, actually go insert it | 206 | * If transitioned from IDLE->ONSTARTQ, actually go insert it |
211 | * on m_StartQueue and give the RunScriptThread() a wake-up. | 207 | * on m_StartQueue and give the RunScriptThread() a wake-up. |
212 | */ | 208 | */ |
213 | if (startIt) { | 209 | if (startIt) |
214 | m_Engine.QueueToStart(this); | 210 | m_Engine.QueueToStart(this); |
215 | } | ||
216 | 211 | ||
217 | /* | 212 | /* |
218 | * Likewise, if the event mask triggered a wake, wake it up. | 213 | * Likewise, if the event mask triggered a wake, wake it up. |
219 | */ | 214 | */ |
220 | if (wakeIt) { | 215 | if (wakeIt) |
216 | { | ||
221 | m_SleepUntil = DateTime.MinValue; | 217 | m_SleepUntil = DateTime.MinValue; |
222 | m_Engine.WakeFromSleep(this); | 218 | m_Engine.WakeFromSleep(this); |
223 | } | 219 | } |
@@ -231,6 +227,7 @@ namespace OpenSim.Region.ScriptEngine.XMREngine | |||
231 | public XMRInstState RunOne() | 227 | public XMRInstState RunOne() |
232 | { | 228 | { |
233 | DateTime now = DateTime.UtcNow; | 229 | DateTime now = DateTime.UtcNow; |
230 | m_SliceStart = Util.GetTimeStampMS(); | ||
234 | 231 | ||
235 | /* | 232 | /* |
236 | * If script has called llSleep(), don't do any more until time is | 233 | * If script has called llSleep(), don't do any more until time is |
@@ -247,7 +244,8 @@ namespace OpenSim.Region.ScriptEngine.XMREngine | |||
247 | * Also, someone may have called Suspend(). | 244 | * Also, someone may have called Suspend(). |
248 | */ | 245 | */ |
249 | m_RunOnePhase = "check m_SuspendCount"; | 246 | m_RunOnePhase = "check m_SuspendCount"; |
250 | if (m_SuspendCount > 0) { | 247 | if (m_SuspendCount > 0) |
248 | { | ||
251 | m_RunOnePhase = "return is suspended"; | 249 | m_RunOnePhase = "return is suspended"; |
252 | return XMRInstState.SUSPENDED; | 250 | return XMRInstState.SUSPENDED; |
253 | } | 251 | } |
@@ -258,7 +256,8 @@ namespace OpenSim.Region.ScriptEngine.XMREngine | |||
258 | * back right away, delay a bit so we don't get in infinite loop. | 256 | * back right away, delay a bit so we don't get in infinite loop. |
259 | */ | 257 | */ |
260 | m_RunOnePhase = "lock m_RunLock"; | 258 | m_RunOnePhase = "lock m_RunLock"; |
261 | if (!Monitor.TryEnter (m_RunLock)) { | 259 | if (!Monitor.TryEnter (m_RunLock)) |
260 | { | ||
262 | m_SleepUntil = now.AddMilliseconds(3); | 261 | m_SleepUntil = now.AddMilliseconds(3); |
263 | m_RunOnePhase = "return was locked"; | 262 | m_RunOnePhase = "return was locked"; |
264 | return XMRInstState.ONSLEEPQ; | 263 | return XMRInstState.ONSLEEPQ; |
@@ -282,7 +281,7 @@ namespace OpenSim.Region.ScriptEngine.XMREngine | |||
282 | /* | 281 | /* |
283 | * Do some more of the last event if it didn't finish. | 282 | * Do some more of the last event if it didn't finish. |
284 | */ | 283 | */ |
285 | else if (this.eventCode != ScriptEventCode.None) | 284 | else if (eventCode != ScriptEventCode.None) |
286 | { | 285 | { |
287 | lock (m_QueueLock) | 286 | lock (m_QueueLock) |
288 | { | 287 | { |
@@ -336,10 +335,10 @@ namespace OpenSim.Region.ScriptEngine.XMREngine | |||
336 | if (m_EventQueue.First != null) | 335 | if (m_EventQueue.First != null) |
337 | { | 336 | { |
338 | evt = m_EventQueue.First.Value; | 337 | evt = m_EventQueue.First.Value; |
338 | evc = (ScriptEventCode)Enum.Parse (typeof (ScriptEventCode), | ||
339 | evt.EventName); | ||
339 | if (m_DetachQuantum > 0) | 340 | if (m_DetachQuantum > 0) |
340 | { | 341 | { |
341 | evc = (ScriptEventCode)Enum.Parse (typeof (ScriptEventCode), | ||
342 | evt.EventName); | ||
343 | if (evc != ScriptEventCode.attach) | 342 | if (evc != ScriptEventCode.attach) |
344 | { | 343 | { |
345 | /* | 344 | /* |
@@ -356,9 +355,8 @@ namespace OpenSim.Region.ScriptEngine.XMREngine | |||
356 | } | 355 | } |
357 | } | 356 | } |
358 | m_EventQueue.RemoveFirst(); | 357 | m_EventQueue.RemoveFirst(); |
359 | evc = (ScriptEventCode)Enum.Parse (typeof (ScriptEventCode), | 358 | if (evc >= 0) |
360 | evt.EventName); | 359 | m_EventCounts[(int)evc] --; |
361 | if ((int)evc >= 0) m_EventCounts[(int)evc] --; | ||
362 | } | 360 | } |
363 | 361 | ||
364 | /* | 362 | /* |
@@ -483,28 +481,25 @@ namespace OpenSim.Region.ScriptEngine.XMREngine | |||
483 | * We use this.eventCode == ScriptEventCode.None to indicate we are idle. | 481 | * We use this.eventCode == ScriptEventCode.None to indicate we are idle. |
484 | * So trying to execute ScriptEventCode.None might make a mess. | 482 | * So trying to execute ScriptEventCode.None might make a mess. |
485 | */ | 483 | */ |
486 | if (eventCode == ScriptEventCode.None) { | 484 | if (eventCode == ScriptEventCode.None) |
487 | return new Exception ("Can't process ScriptEventCode.None"); | 485 | return new Exception ("Can't process ScriptEventCode.None"); |
488 | } | ||
489 | 486 | ||
490 | /* | 487 | /* |
491 | * Silly to even try if there is no handler defined for this event. | 488 | * Silly to even try if there is no handler defined for this event. |
492 | */ | 489 | */ |
493 | if (((int)eventCode >= 0) && (m_ObjCode.scriptEventHandlerTable[this.stateCode,(int)eventCode] == null)) { | 490 | if ((eventCode >= 0) && (m_ObjCode.scriptEventHandlerTable[this.stateCode,(int)eventCode] == null)) |
494 | return null; | 491 | return null; |
495 | } | ||
496 | 492 | ||
497 | /* | 493 | /* |
498 | * The microthread shouldn't be processing any event code. | 494 | * The microthread shouldn't be processing any event code. |
499 | * These are assert checks so we throw them directly as exceptions. | 495 | * These are assert checks so we throw them directly as exceptions. |
500 | */ | 496 | */ |
501 | if (this.eventCode != ScriptEventCode.None) { | 497 | if (this.eventCode != ScriptEventCode.None) |
502 | throw new Exception ("still processing event " + this.eventCode.ToString ()); | 498 | throw new Exception ("still processing event " + this.eventCode.ToString ()); |
503 | } | 499 | |
504 | int active = microthread.Active (); | 500 | int active = microthread.Active (); |
505 | if (active != 0) { | 501 | if (active != 0) |
506 | throw new Exception ("microthread is active " + active.ToString ()); | 502 | throw new Exception ("microthread is active " + active.ToString ()); |
507 | } | ||
508 | 503 | ||
509 | /* | 504 | /* |
510 | * Save eventCode so we know what event handler to run in the microthread. | 505 | * Save eventCode so we know what event handler to run in the microthread. |
@@ -956,19 +951,28 @@ namespace OpenSim.Region.ScriptEngine.XMREngine | |||
956 | */ | 951 | */ |
957 | public override void CheckRunWork () | 952 | public override void CheckRunWork () |
958 | { | 953 | { |
954 | if(!suspendOnCheckRunHold && ! suspendOnCheckRunTemp) | ||
955 | { | ||
956 | if(Util.GetTimeStampMS() - m_SliceStart < 60.0) | ||
957 | return; | ||
958 | suspendOnCheckRunTemp = true; | ||
959 | } | ||
960 | |||
959 | m_CheckRunPhase = "entered"; | 961 | m_CheckRunPhase = "entered"; |
960 | 962 | ||
961 | /* | 963 | /* |
962 | * Stay stuck in this loop as long as something wants us suspended. | 964 | * Stay stuck in this loop as long as something wants us suspended. |
963 | */ | 965 | */ |
964 | while (suspendOnCheckRunHold || suspendOnCheckRunTemp) { | 966 | while (suspendOnCheckRunHold || suspendOnCheckRunTemp) |
967 | { | ||
965 | m_CheckRunPhase = "top of while"; | 968 | m_CheckRunPhase = "top of while"; |
966 | 969 | ||
967 | /* | 970 | /* |
968 | * See if MigrateOutEventHandler() has been called. | 971 | * See if MigrateOutEventHandler() has been called. |
969 | * If so, dump our stack to stackFrames and unwind. | 972 | * If so, dump our stack to stackFrames and unwind. |
970 | */ | 973 | */ |
971 | if (this.captureStackFrames) { | 974 | if (this.captureStackFrames) |
975 | { | ||
972 | 976 | ||
973 | /* | 977 | /* |
974 | * Puque our stack to the output stream. | 978 | * Puque our stack to the output stream. |
@@ -986,7 +990,8 @@ namespace OpenSim.Region.ScriptEngine.XMREngine | |||
986 | * within the functions should do their normal processing instead of trying to | 990 | * within the functions should do their normal processing instead of trying to |
987 | * restore their state. | 991 | * restore their state. |
988 | */ | 992 | */ |
989 | if (this.callMode == CallMode_RESTORE) { | 993 | if (this.callMode == CallMode_RESTORE) |
994 | { | ||
990 | stackFramesRestored = true; | 995 | stackFramesRestored = true; |
991 | this.callMode = CallMode_NORMAL; | 996 | this.callMode = CallMode_NORMAL; |
992 | } | 997 | } |