Yengine try to better recover from invalid state files
parent
295f24fe01
commit
6597b7ab46
|
@ -188,7 +188,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine
|
||||||
// Use the same object code for identical source code
|
// Use the same object code for identical source code
|
||||||
// regardless of asset ID, so we don't care if they
|
// regardless of asset ID, so we don't care if they
|
||||||
// copy scripts or not.
|
// 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);
|
StringBuilder sb = new StringBuilder((256 + 5) / 6);
|
||||||
using (System.Security.Cryptography.SHA256 sha = System.Security.Cryptography.SHA256.Create())
|
using (System.Security.Cryptography.SHA256 sha = System.Security.Cryptography.SHA256.Create())
|
||||||
ByteArrayToSixbitStr(sb, sha.ComputeHash(scbytes));
|
ByteArrayToSixbitStr(sb, sha.ComputeHash(scbytes));
|
||||||
|
@ -378,18 +378,34 @@ namespace OpenSim.Region.ScriptEngine.Yengine
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
string xml;
|
try
|
||||||
using (FileStream fs = File.Open(m_StateFileName,
|
{
|
||||||
|
string xml;
|
||||||
|
using (FileStream fs = File.Open(m_StateFileName,
|
||||||
FileMode.Open,
|
FileMode.Open,
|
||||||
FileAccess.Read))
|
FileAccess.Read))
|
||||||
{
|
{
|
||||||
using(StreamReader ss = new StreamReader(fs))
|
using(StreamReader ss = new StreamReader(fs))
|
||||||
xml = ss.ReadToEnd();
|
xml = ss.ReadToEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
XmlDocument doc = new XmlDocument();
|
XmlDocument doc = new XmlDocument();
|
||||||
doc.LoadXml(xml);
|
doc.LoadXml(xml);
|
||||||
LoadScriptState(doc);
|
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.
|
// Post event(s) saying what caused the script to start.
|
||||||
|
@ -527,11 +543,12 @@ namespace OpenSim.Region.ScriptEngine.Yengine
|
||||||
XmlElement snapshotN = (XmlElement)scriptStateN.SelectSingleNode("Snapshot");
|
XmlElement snapshotN = (XmlElement)scriptStateN.SelectSingleNode("Snapshot");
|
||||||
|
|
||||||
Byte[] data = Convert.FromBase64String(snapshotN.InnerText);
|
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);
|
ms.Write(data, 0, data.Length);
|
||||||
MigrateInEventHandler(ms);
|
ms.Seek(0, SeekOrigin.Begin);
|
||||||
ms.Close();
|
MigrateInEventHandler(ms);
|
||||||
|
}
|
||||||
|
|
||||||
// Restore event queues, preserving any events that queued
|
// Restore event queues, preserving any events that queued
|
||||||
// whilst we were restoring the state
|
// whilst we were restoring the state
|
||||||
|
|
Loading…
Reference in New Issue