From 669f55340005a450fc236db3b9d660878062219c Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sun, 7 Sep 2008 22:01:25 +0000 Subject: Xengine patch to force a persistence save on script creation. This prevents duplicate delivery of state_entry if a region is restarted just after saving the script. Changes script state saves to no longer abort long- running event handlers. Queues the save instead. Adds shutdown handler to save script state on irderly shutdown --- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 27 +++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/XEngine') diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 485531d..303e5e4 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -210,6 +210,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine m_Scene.EventManager.OnScriptReset += OnScriptReset; m_Scene.EventManager.OnStartScript += OnStartScript; m_Scene.EventManager.OnStopScript += OnStopScript; + m_Scene.EventManager.OnShutdown += OnShutdown; m_AsyncCommands = new AsyncCommandManager(this); @@ -247,7 +248,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine Object[] p = (Object[])o; int saveTime = (int)p[0]; - System.Threading.Thread.Sleep(saveTime); + if (saveTime > 0) + System.Threading.Thread.Sleep(saveTime); // m_log.Debug("[XEngine] Backing up script states"); @@ -275,8 +277,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine instances.Clear(); - m_ThreadPool.QueueWorkItem(new WorkItemCallback(this.DoBackup), - new Object[] { saveTime }); + if (saveTime > 0) + m_ThreadPool.QueueWorkItem(new WorkItemCallback(this.DoBackup), + new Object[] { saveTime }); return 0; } @@ -840,5 +843,23 @@ namespace OpenSim.Region.ScriptEngine.XEngine { return GetScriptState(itemID); } + + public void OnShutdown() + { + List instances = new List(); + + lock (m_Scripts) + { + foreach (IScriptInstance instance in m_Scripts.Values) + instances.Add(instance); + } + + foreach (IScriptInstance i in instances) + { + i.Stop(50); + } + + DoBackup(new Object[] {0}); + } } } -- cgit v1.1