aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2011-10-19 21:30:37 +0100
committerJustin Clark-Casey (justincc)2011-10-19 21:30:37 +0100
commit5607fd3af828846291de3358067bb1214619489e (patch)
tree09459fb954c1944ff0836d59e2e36ffad416b70d /OpenSim/Region
parentAdd "scripts suspend" and "scripts resume" commands. (diff)
downloadopensim-SC-5607fd3af828846291de3358067bb1214619489e.zip
opensim-SC-5607fd3af828846291de3358067bb1214619489e.tar.gz
opensim-SC-5607fd3af828846291de3358067bb1214619489e.tar.bz2
opensim-SC-5607fd3af828846291de3358067bb1214619489e.tar.xz
Fix resume scripts.
On resume, we need to place requeue the script for event processing if there are any events on the queue. Also need to do this under m_Script lock in order to avoid a race
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs40
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/XEngine.cs2
2 files changed, 33 insertions, 9 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
index 893f3ef..f9af9c1 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
@@ -55,7 +55,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
55{ 55{
56 public class ScriptInstance : MarshalByRefObject, IScriptInstance 56 public class ScriptInstance : MarshalByRefObject, IScriptInstance
57 { 57 {
58// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 58 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
59 59
60 private IScriptEngine m_Engine; 60 private IScriptEngine m_Engine;
61 private IScriptWorkItem m_CurrentResult = null; 61 private IScriptWorkItem m_CurrentResult = null;
@@ -138,7 +138,31 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
138 set { m_RunEvents = value; } 138 set { m_RunEvents = value; }
139 } 139 }
140 140
141 public bool Suspended { get; set; } 141 public bool Suspended
142 {
143 get { return m_Suspended; }
144
145 set
146 {
147 // Need to do this inside a lock in order to avoid races with EventProcessor()
148 lock (m_Script)
149 {
150 bool wasSuspended = m_Suspended;
151 m_Suspended = value;
152
153 if (wasSuspended && !m_Suspended)
154 {
155 lock (m_EventQueue)
156 {
157 // Need to place ourselves back in a work item if there are events to process
158 if ((m_EventQueue.Count > 0) && m_RunEvents && (!m_ShuttingDown))
159 m_CurrentResult = m_Engine.QueueEventHandler(this);
160 }
161 }
162 }
163 }
164 }
165 private bool m_Suspended;
142 166
143 public bool ShuttingDown 167 public bool ShuttingDown
144 { 168 {
@@ -645,13 +669,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
645 /// <returns></returns> 669 /// <returns></returns>
646 public object EventProcessor() 670 public object EventProcessor()
647 { 671 {
648// m_log.DebugFormat("[XEngine]: EventProcessor() invoked for {0}.{1}", PrimName, ScriptName);
649
650 if (Suspended)
651 return 0;
652
653 lock (m_Script) 672 lock (m_Script)
654 { 673 {
674// m_log.DebugFormat("[XEngine]: EventProcessor() invoked for {0}.{1}", PrimName, ScriptName);
675
676 if (Suspended)
677 return 0;
678
655 EventParams data = null; 679 EventParams data = null;
656 680
657 lock (m_EventQueue) 681 lock (m_EventQueue)
@@ -689,7 +713,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
689 { 713 {
690 // m_log.DebugFormat("[Script] Script {0}.{1} state set to {2}", 714 // m_log.DebugFormat("[Script] Script {0}.{1} state set to {2}",
691 // m_PrimName, m_ScriptName, data.Params[0].ToString()); 715 // m_PrimName, m_ScriptName, data.Params[0].ToString());
692 m_State=data.Params[0].ToString(); 716 m_State = data.Params[0].ToString();
693 AsyncCommandManager.RemoveScript(m_Engine, 717 AsyncCommandManager.RemoveScript(m_Engine,
694 m_LocalID, m_ItemID); 718 m_LocalID, m_ItemID);
695 719
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index bb08d90..5ee8dbf 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -946,7 +946,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
946 if (!m_Scripts.ContainsKey(itemID)) 946 if (!m_Scripts.ContainsKey(itemID))
947 return; 947 return;
948 948
949 instance=m_Scripts[itemID]; 949 instance = m_Scripts[itemID];
950 m_Scripts.Remove(itemID); 950 m_Scripts.Remove(itemID);
951 } 951 }
952 952