Yengine try to better recover from invalid state files

0.9.1.0-post-fixes
UbitUmarov 2018-12-08 03:31:47 +00:00
parent 295f24fe01
commit 6597b7ab46
1 changed files with 32 additions and 15 deletions

View File

@ -188,7 +188,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine
// Use the same object code for identical source code
// regardless of asset ID, so we don't care if they
// copy scripts or not.
byte[] scbytes = System.Text.Encoding.UTF8.GetBytes(m_SourceCode);
byte[] scbytes = System.Text.Encoding.UTF8.GetBytes(m_SourceCode + migrationVersion.ToString());
StringBuilder sb = new StringBuilder((256 + 5) / 6);
using (System.Security.Cryptography.SHA256 sha = System.Security.Cryptography.SHA256.Create())
ByteArrayToSixbitStr(sb, sha.ComputeHash(scbytes));
@ -377,6 +377,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine
zeroDetectParams));
}
else
{
try
{
string xml;
using (FileStream fs = File.Open(m_StateFileName,
@ -391,6 +393,20 @@ namespace OpenSim.Region.ScriptEngine.Yengine
doc.LoadXml(xml);
LoadScriptState(doc);
}
catch (Exception e)
{
m_Running = true; // event processing is enabled
eventCode = ScriptEventCode.None; // not processing any event
// default state_entry() must initialize global variables
doGblInit = true;
stateCode = 0;
PostEvent(new EventParams("state_entry",
zeroObjectArray,
zeroDetectParams));
}
}
// Post event(s) saying what caused the script to start.
if(m_PostOnRez)
@ -527,11 +543,12 @@ namespace OpenSim.Region.ScriptEngine.Yengine
XmlElement snapshotN = (XmlElement)scriptStateN.SelectSingleNode("Snapshot");
Byte[] data = Convert.FromBase64String(snapshotN.InnerText);
MemoryStream ms = new MemoryStream();
using(MemoryStream ms = new MemoryStream())
{
ms.Write(data, 0, data.Length);
ms.Seek(0, SeekOrigin.Begin);
MigrateInEventHandler(ms);
ms.Close();
}
// Restore event queues, preserving any events that queued
// whilst we were restoring the state