From 3cf7fb4eca2ad57835311e8098868f2571709392 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Wed, 19 Oct 2011 20:53:24 +0100 Subject: [PATCH] Add "scripts suspend" and "scripts resume" commands. These aim currently to suspend and resume all scripts. However, resume isn't currently working due to what looks like a bug in resume functionality itself. --- .../Shared/Instance/ScriptInstance.cs | 6 ++- .../Region/ScriptEngine/XEngine/XEngine.cs | 50 ++++++++++++++++++- 2 files changed, 53 insertions(+), 3 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index 9d48e9466a..893f3ef60a 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 { public class ScriptInstance : MarshalByRefObject, IScriptInstance { - // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); +// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private IScriptEngine m_Engine; private IScriptWorkItem m_CurrentResult = null; @@ -645,6 +645,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance /// public object EventProcessor() { +// m_log.DebugFormat("[XEngine]: EventProcessor() invoked for {0}.{1}", PrimName, ScriptName); + if (Suspended) return 0; @@ -679,7 +681,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance m_CollisionInQueue = false; } - //m_log.DebugFormat("[XEngine]: Processing event {0} for {1}", data.EventName, this); +// m_log.DebugFormat("[XEngine]: Processing event {0} for {1}", data.EventName, this); m_DetectParams = data.DetectParams; diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 304848e06a..bb08d90483 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -274,6 +274,16 @@ namespace OpenSim.Region.ScriptEngine.XEngine MainConsole.Instance.Commands.AddCommand( "scripts", false, "show scripts", "show scripts", "Show script information", "Synonym for scripts show command", HandleShowScripts); + + MainConsole.Instance.Commands.AddCommand( + "scripts", false, "scripts suspend", "scripts suspend", "Suspend all scripts", + "Suspends all currently running scripts. This only suspends event delivery, it will not suspend a" + + " script that is currently processing an event.", + HandleSuspendScripts); + + MainConsole.Instance.Commands.AddCommand( + "scripts", false, "scripts resume", "scripts resume", "Resume all scripts", + "Resumes all currently suspended scripts", HandleResumeScripts); } public void HandleShowScripts(string module, string[] cmdparams) @@ -313,6 +323,44 @@ namespace OpenSim.Region.ScriptEngine.XEngine } } + public void HandleSuspendScripts(string module, string[] cmdparams) + { + lock (m_Scripts) + { + foreach (IScriptInstance instance in m_Scripts.Values) + { + if (!instance.Suspended) + { + instance.Suspend(); + + SceneObjectPart sop = m_Scene.GetSceneObjectPart(instance.ObjectID); + MainConsole.Instance.OutputFormat( + "Suspended {0}.{1}, item UUID {2}, prim UUID {3} @ {4}", + instance.PrimName, instance.ScriptName, instance.ItemID, instance.ObjectID, sop.AbsolutePosition); + } + } + } + } + + public void HandleResumeScripts(string module, string[] cmdparams) + { + lock (m_Scripts) + { + foreach (IScriptInstance instance in m_Scripts.Values) + { + if (instance.Suspended) + { + instance.Resume(); + + SceneObjectPart sop = m_Scene.GetSceneObjectPart(instance.ObjectID); + MainConsole.Instance.OutputFormat( + "Resumed {0}.{1}, item UUID {2}, prim UUID {3} @ {4}", + instance.PrimName, instance.ScriptName, instance.ItemID, instance.ObjectID, sop.AbsolutePosition); + } + } + } + } + public void RemoveRegion(Scene scene) { if (!m_Enabled) @@ -841,7 +889,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine m_log.DebugFormat( "[XEngine] Loaded script {0}.{1}, item UUID {2}, prim UUID {3} @ {4}.{5}", - part.ParentGroup.RootPart.Name, item.Name, itemID, part.UUID, + part.ParentGroup.RootPart.Name, item.Name, itemID, part.UUID, part.ParentGroup.RootPart.AbsolutePosition, part.ParentGroup.Scene.RegionInfo.RegionName); if (presence != null)