aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorUbitUmarov2018-12-08 03:31:47 +0000
committerUbitUmarov2018-12-08 03:31:47 +0000
commit6597b7ab462e660c63677c861551b8d2a6a67278 (patch)
treeec31c3156df6a9968d404546903b303123cbbee1 /OpenSim/Region
parentmantis 8416: change string compare method (actually on previus commit) (diff)
downloadopensim-SC-6597b7ab462e660c63677c861551b8d2a6a67278.zip
opensim-SC-6597b7ab462e660c63677c861551b8d2a6a67278.tar.gz
opensim-SC-6597b7ab462e660c63677c861551b8d2a6a67278.tar.bz2
opensim-SC-6597b7ab462e660c63677c861551b8d2a6a67278.tar.xz
Yengine try to better recover from invalid state files
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/ScriptEngine/YEngine/XMRInstCtor.cs45
1 files changed, 31 insertions, 14 deletions
diff --git a/OpenSim/Region/ScriptEngine/YEngine/XMRInstCtor.cs b/OpenSim/Region/ScriptEngine/YEngine/XMRInstCtor.cs
index c2cf6cf..2cea94c 100644
--- a/OpenSim/Region/ScriptEngine/YEngine/XMRInstCtor.cs
+++ b/OpenSim/Region/ScriptEngine/YEngine/XMRInstCtor.cs
@@ -188,7 +188,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine
188 // Use the same object code for identical source code 188 // Use the same object code for identical source code
189 // regardless of asset ID, so we don't care if they 189 // regardless of asset ID, so we don't care if they
190 // copy scripts or not. 190 // copy scripts or not.
191 byte[] scbytes = System.Text.Encoding.UTF8.GetBytes(m_SourceCode); 191 byte[] scbytes = System.Text.Encoding.UTF8.GetBytes(m_SourceCode + migrationVersion.ToString());
192 StringBuilder sb = new StringBuilder((256 + 5) / 6); 192 StringBuilder sb = new StringBuilder((256 + 5) / 6);
193 using (System.Security.Cryptography.SHA256 sha = System.Security.Cryptography.SHA256.Create()) 193 using (System.Security.Cryptography.SHA256 sha = System.Security.Cryptography.SHA256.Create())
194 ByteArrayToSixbitStr(sb, sha.ComputeHash(scbytes)); 194 ByteArrayToSixbitStr(sb, sha.ComputeHash(scbytes));
@@ -378,18 +378,34 @@ namespace OpenSim.Region.ScriptEngine.Yengine
378 } 378 }
379 else 379 else
380 { 380 {
381 string xml; 381 try
382 using (FileStream fs = File.Open(m_StateFileName, 382 {
383 string xml;
384 using (FileStream fs = File.Open(m_StateFileName,
383 FileMode.Open, 385 FileMode.Open,
384 FileAccess.Read)) 386 FileAccess.Read))
385 { 387 {
386 using(StreamReader ss = new StreamReader(fs)) 388 using(StreamReader ss = new StreamReader(fs))
387 xml = ss.ReadToEnd(); 389 xml = ss.ReadToEnd();
390 }
391
392 XmlDocument doc = new XmlDocument();
393 doc.LoadXml(xml);
394 LoadScriptState(doc);
388 } 395 }
396 catch (Exception e)
397 {
398 m_Running = true; // event processing is enabled
399 eventCode = ScriptEventCode.None; // not processing any event
400
401 // default state_entry() must initialize global variables
402 doGblInit = true;
403 stateCode = 0;
389 404
390 XmlDocument doc = new XmlDocument(); 405 PostEvent(new EventParams("state_entry",
391 doc.LoadXml(xml); 406 zeroObjectArray,
392 LoadScriptState(doc); 407 zeroDetectParams));
408 }
393 } 409 }
394 410
395 // Post event(s) saying what caused the script to start. 411 // Post event(s) saying what caused the script to start.
@@ -527,11 +543,12 @@ namespace OpenSim.Region.ScriptEngine.Yengine
527 XmlElement snapshotN = (XmlElement)scriptStateN.SelectSingleNode("Snapshot"); 543 XmlElement snapshotN = (XmlElement)scriptStateN.SelectSingleNode("Snapshot");
528 544
529 Byte[] data = Convert.FromBase64String(snapshotN.InnerText); 545 Byte[] data = Convert.FromBase64String(snapshotN.InnerText);
530 MemoryStream ms = new MemoryStream(); 546 using(MemoryStream ms = new MemoryStream())
531 ms.Write(data, 0, data.Length); 547 {
532 ms.Seek(0, SeekOrigin.Begin); 548 ms.Write(data, 0, data.Length);
533 MigrateInEventHandler(ms); 549 ms.Seek(0, SeekOrigin.Begin);
534 ms.Close(); 550 MigrateInEventHandler(ms);
551 }
535 552
536 // Restore event queues, preserving any events that queued 553 // Restore event queues, preserving any events that queued
537 // whilst we were restoring the state 554 // whilst we were restoring the state