aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
diff options
context:
space:
mode:
authorMelanie Thielker2008-09-07 22:01:25 +0000
committerMelanie Thielker2008-09-07 22:01:25 +0000
commit669f55340005a450fc236db3b9d660878062219c (patch)
tree647652958bb8714e8422660a34e8da76823459fc /OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
parentMantis #2138 (diff)
downloadopensim-SC_OLD-669f55340005a450fc236db3b9d660878062219c.zip
opensim-SC_OLD-669f55340005a450fc236db3b9d660878062219c.tar.gz
opensim-SC_OLD-669f55340005a450fc236db3b9d660878062219c.tar.bz2
opensim-SC_OLD-669f55340005a450fc236db3b9d660878062219c.tar.xz
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
Diffstat (limited to 'OpenSim/Region/ScriptEngine/XEngine/XEngine.cs')
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/XEngine.cs27
1 files changed, 24 insertions, 3 deletions
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
210 m_Scene.EventManager.OnScriptReset += OnScriptReset; 210 m_Scene.EventManager.OnScriptReset += OnScriptReset;
211 m_Scene.EventManager.OnStartScript += OnStartScript; 211 m_Scene.EventManager.OnStartScript += OnStartScript;
212 m_Scene.EventManager.OnStopScript += OnStopScript; 212 m_Scene.EventManager.OnStopScript += OnStopScript;
213 m_Scene.EventManager.OnShutdown += OnShutdown;
213 214
214 m_AsyncCommands = new AsyncCommandManager(this); 215 m_AsyncCommands = new AsyncCommandManager(this);
215 216
@@ -247,7 +248,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
247 Object[] p = (Object[])o; 248 Object[] p = (Object[])o;
248 int saveTime = (int)p[0]; 249 int saveTime = (int)p[0];
249 250
250 System.Threading.Thread.Sleep(saveTime); 251 if (saveTime > 0)
252 System.Threading.Thread.Sleep(saveTime);
251 253
252// m_log.Debug("[XEngine] Backing up script states"); 254// m_log.Debug("[XEngine] Backing up script states");
253 255
@@ -275,8 +277,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine
275 277
276 instances.Clear(); 278 instances.Clear();
277 279
278 m_ThreadPool.QueueWorkItem(new WorkItemCallback(this.DoBackup), 280 if (saveTime > 0)
279 new Object[] { saveTime }); 281 m_ThreadPool.QueueWorkItem(new WorkItemCallback(this.DoBackup),
282 new Object[] { saveTime });
280 283
281 return 0; 284 return 0;
282 } 285 }
@@ -840,5 +843,23 @@ namespace OpenSim.Region.ScriptEngine.XEngine
840 { 843 {
841 return GetScriptState(itemID); 844 return GetScriptState(itemID);
842 } 845 }
846
847 public void OnShutdown()
848 {
849 List<IScriptInstance> instances = new List<IScriptInstance>();
850
851 lock (m_Scripts)
852 {
853 foreach (IScriptInstance instance in m_Scripts.Values)
854 instances.Add(instance);
855 }
856
857 foreach (IScriptInstance i in instances)
858 {
859 i.Stop(50);
860 }
861
862 DoBackup(new Object[] {0});
863 }
843 } 864 }
844} 865}