aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2013-01-16 01:45:09 +0000
committerJustin Clark-Casey (justincc)2013-01-16 01:45:09 +0000
commitb8949024bc55c62b9268b35d4f2a568760b9d7d3 (patch)
tree7b8d984c957fab7aba5aceec66967adb5e8a0d51 /OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
parentMerge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff)
downloadopensim-SC_OLD-b8949024bc55c62b9268b35d4f2a568760b9d7d3.zip
opensim-SC_OLD-b8949024bc55c62b9268b35d4f2a568760b9d7d3.tar.gz
opensim-SC_OLD-b8949024bc55c62b9268b35d4f2a568760b9d7d3.tar.bz2
opensim-SC_OLD-b8949024bc55c62b9268b35d4f2a568760b9d7d3.tar.xz
Revert "Implement co-operative script termination if termination comes during a script wait event (llSleep(), etc.)"
Doing this as a favour to Melanie. This will be back with passing the wait handles directly to the api. This reverts commit 1b5c41c14ad11325be249ea1cce3c65d4d6a89be.
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs52
1 files changed, 3 insertions, 49 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
index 00048a1..a2ff51b 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
@@ -200,10 +200,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
200 200
201 public static readonly long MaxMeasurementPeriod = 30 * TimeSpan.TicksPerMinute; 201 public static readonly long MaxMeasurementPeriod = 30 * TimeSpan.TicksPerMinute;
202 202
203 public bool CoopTermination { get; private set; }
204
205 public EventWaitHandle CoopSleepHandle { get; private set; }
206
207 public void ClearQueue() 203 public void ClearQueue()
208 { 204 {
209 m_TimerQueued = false; 205 m_TimerQueued = false;
@@ -237,12 +233,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
237 m_postOnRez = postOnRez; 233 m_postOnRez = postOnRez;
238 m_AttachedAvatar = Part.ParentGroup.AttachedAvatar; 234 m_AttachedAvatar = Part.ParentGroup.AttachedAvatar;
239 m_RegionID = Part.ParentGroup.Scene.RegionInfo.RegionID; 235 m_RegionID = Part.ParentGroup.Scene.RegionInfo.RegionID;
240
241 if (Engine.Config.GetString("ScriptStopStrategy", "abort") == "co-op")
242 {
243 CoopTermination = true;
244 CoopSleepHandle = new AutoResetEvent(false);
245 }
246 } 236 }
247 237
248 /// <summary> 238 /// <summary>
@@ -542,34 +532,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
542 } 532 }
543 533
544 // Wait for the current event to complete. 534 // Wait for the current event to complete.
545 if (!m_InSelfDelete) 535 if (!m_InSelfDelete && workItem.Wait(new TimeSpan((long)timeout * 100000)))
546 { 536 {
547 if (!CoopTermination) 537 return true;
548 {
549 // If we're not co-operative terminating then try and wait for the event to complete before stopping
550 if (workItem.Wait(new TimeSpan((long)timeout * 100000)))
551 return true;
552 }
553 else
554 {
555 m_log.DebugFormat(
556 "[SCRIPT INSTANCE]: Co-operatively stopping script {0} {1} in {2} {3}",
557 ScriptName, ItemID, PrimName, ObjectID);
558
559 // This will terminate the event on next handle check by the script.
560 CoopSleepHandle.Set();
561
562 // For now, we will wait forever since the event should always cleanly terminate once LSL loop
563 // checking is implemented. May want to allow a shorter timeout option later.
564 if (workItem.Wait(TimeSpan.MaxValue))
565 {
566 m_log.DebugFormat(
567 "[SCRIPT INSTANCE]: Co-operatively stopped script {0} {1} in {2} {3}",
568 ScriptName, ItemID, PrimName, ObjectID);
569
570 return true;
571 }
572 }
573 } 538 }
574 539
575 lock (EventQueue) 540 lock (EventQueue)
@@ -582,7 +547,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
582 547
583 // If the event still hasn't stopped and we the stop isn't the result of script or object removal, then 548 // If the event still hasn't stopped and we the stop isn't the result of script or object removal, then
584 // forcibly abort the work item (this aborts the underlying thread). 549 // forcibly abort the work item (this aborts the underlying thread).
585 // Co-operative termination should never reach this point.
586 if (!m_InSelfDelete) 550 if (!m_InSelfDelete)
587 { 551 {
588 m_log.DebugFormat( 552 m_log.DebugFormat(
@@ -822,11 +786,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
822 m_InEvent = false; 786 m_InEvent = false;
823 m_CurrentEvent = String.Empty; 787 m_CurrentEvent = String.Empty;
824 788
825 if ((!(e is TargetInvocationException) 789 if ((!(e is TargetInvocationException) || (!(e.InnerException is SelfDeleteException) && !(e.InnerException is ScriptDeleteException))) && !(e is ThreadAbortException))
826 || (!(e.InnerException is SelfDeleteException)
827 && !(e.InnerException is ScriptDeleteException)
828 && !(e.InnerException is ScriptCoopStopException)))
829 && !(e is ThreadAbortException))
830 { 790 {
831 try 791 try
832 { 792 {
@@ -874,12 +834,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
874 m_InSelfDelete = true; 834 m_InSelfDelete = true;
875 Part.Inventory.RemoveInventoryItem(ItemID); 835 Part.Inventory.RemoveInventoryItem(ItemID);
876 } 836 }
877 else if ((e is TargetInvocationException) && (e.InnerException is ScriptCoopStopException))
878 {
879 m_log.DebugFormat(
880 "[SCRIPT INSTANCE]: Script {0}.{1} in event {2}, state {3} stopped co-operatively.",
881 PrimName, ScriptName, data.EventName, State);
882 }
883 } 837 }
884 } 838 }
885 } 839 }