aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared
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/Shared
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 '')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs28
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Instance/ScriptSerializer.cs6
2 files changed, 28 insertions, 6 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
index d35bfa8..08f9545 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
@@ -73,6 +73,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
73 private string m_CurrentEvent = String.Empty; 73 private string m_CurrentEvent = String.Empty;
74 private bool m_InSelfDelete = false; 74 private bool m_InSelfDelete = false;
75 private int m_MaxScriptQueue; 75 private int m_MaxScriptQueue;
76 private bool m_SaveState = true;
76 77
77 private Dictionary<string,IScriptApi> m_Apis = new Dictionary<string,IScriptApi>(); 78 private Dictionary<string,IScriptApi> m_Apis = new Dictionary<string,IScriptApi>();
78 79
@@ -213,6 +214,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
213 return; 214 return;
214 } 215 }
215 216
217 m_SaveState = true;
218
216 string savedState = Path.Combine(Path.GetDirectoryName(assembly), 219 string savedState = Path.Combine(Path.GetDirectoryName(assembly),
217 m_ItemID.ToString() + ".state"); 220 m_ItemID.ToString() + ".state");
218 if (File.Exists(savedState)) 221 if (File.Exists(savedState))
@@ -257,6 +260,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
257 // we get new rez events on sim restart, too 260 // we get new rez events on sim restart, too
258 // but if there is state, then we fire the change 261 // but if there is state, then we fire the change
259 // event 262 // event
263
264 // We loaded state, don't force a re-save
265 m_SaveState = false;
266
260 if (stateSource == StateSource.NewRez) 267 if (stateSource == StateSource.NewRez)
261 { 268 {
262// m_Engine.Log.Debug("[Script] Posted changed(CHANGED_REGION_RESTART) to script"); 269// m_Engine.Log.Debug("[Script] Posted changed(CHANGED_REGION_RESTART) to script");
@@ -487,6 +494,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
487 494
488 m_InEvent = false; 495 m_InEvent = false;
489 m_CurrentEvent = String.Empty; 496 m_CurrentEvent = String.Empty;
497
498 if (m_SaveState)
499 {
500 // This will be the very first event we deliver
501 // (state_entry) in defualt state
502 //
503
504 SaveState(m_Assembly);
505
506 m_SaveState = false;
507 }
490 } 508 }
491 catch (Exception e) 509 catch (Exception e)
492 { 510 {
@@ -589,6 +607,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
589 m_State = "default"; 607 m_State = "default";
590 if (running) 608 if (running)
591 Start(); 609 Start();
610 m_SaveState = true;
592 PostEvent(new EventParams("state_entry", 611 PostEvent(new EventParams("state_entry",
593 new Object[0], new DetectParams[0])); 612 new Object[0], new DetectParams[0]));
594 } 613 }
@@ -607,6 +626,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
607 async.RemoveScript(m_LocalID, m_ItemID); 626 async.RemoveScript(m_LocalID, m_ItemID);
608 if (m_CurrentEvent != "state_entry") 627 if (m_CurrentEvent != "state_entry")
609 { 628 {
629 m_SaveState = true;
610 PostEvent(new EventParams("state_entry", 630 PostEvent(new EventParams("state_entry",
611 new Object[0], new DetectParams[0])); 631 new Object[0], new DetectParams[0]));
612 } 632 }
@@ -640,6 +660,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
640 660
641 public void SaveState(string assembly) 661 public void SaveState(string assembly)
642 { 662 {
663 // If we're currently in an event, just tell it to save upon return
664 //
665 if(m_InEvent)
666 {
667 m_SaveState = true;
668 return;
669 }
670
643 AsyncCommandManager async = (AsyncCommandManager)m_Engine.AsyncCommands; 671 AsyncCommandManager async = (AsyncCommandManager)m_Engine.AsyncCommands;
644 PluginData = async.GetSerializationData(m_ItemID); 672 PluginData = async.GetSerializationData(m_ItemID);
645 673
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptSerializer.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptSerializer.cs
index bc9b174..a794f02 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptSerializer.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptSerializer.cs
@@ -56,9 +56,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
56 { 56 {
57 bool running = instance.Running; 57 bool running = instance.Running;
58 58
59 if (running)
60 instance.Stop(50);
61
62 XmlDocument xmldoc = new XmlDocument(); 59 XmlDocument xmldoc = new XmlDocument();
63 60
64 XmlNode xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration, 61 XmlNode xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration,
@@ -182,9 +179,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
182 179
183 rootElement.AppendChild(plugins); 180 rootElement.AppendChild(plugins);
184 181
185 if (running)
186 instance.Start();
187
188 return xmldoc.InnerXml; 182 return xmldoc.InnerXml;
189 } 183 }
190 184