If there are any exceptions in XEngine.DoOnRezScriptQueue() then log the error and always set m_CurrentCompile = null

Setting m_CurrentCompile = null in the finally block reduces the risk that an exception could permanently stop any future scripts compiling until the simulator is restarted.
If an exception is seen from this then please report and further changes to fix the bug or improve compiling reliability can be made.
mb-throttle-test
Justin Clark-Casey (justincc) 2014-11-29 01:42:52 +00:00
parent 55e064baf7
commit 690fe0c5e5
1 changed files with 48 additions and 36 deletions

View File

@ -1046,49 +1046,61 @@ namespace OpenSim.Region.ScriptEngine.XEngine
public Object DoOnRezScriptQueue(Object dummy) public Object DoOnRezScriptQueue(Object dummy)
{ {
if (m_InitialStartup) try
{ {
// This delay exists to stop mono problems where script compilation and startup would stop the sim if (m_InitialStartup)
// working properly for the session.
System.Threading.Thread.Sleep(m_StartDelay);
m_log.InfoFormat("[XEngine]: Performing initial script startup on {0}", m_Scene.Name);
}
object[] o;
int scriptsStarted = 0;
while (m_CompileQueue.Dequeue(out o))
{
if (DoOnRezScript(o))
{ {
scriptsStarted++; // This delay exists to stop mono problems where script compilation and startup would stop the sim
// working properly for the session.
System.Threading.Thread.Sleep(m_StartDelay);
if (m_InitialStartup) m_log.InfoFormat("[XEngine]: Performing initial script startup on {0}", m_Scene.Name);
if (scriptsStarted % 50 == 0)
m_log.InfoFormat(
"[XEngine]: Started {0} scripts in {1}", scriptsStarted, m_Scene.Name);
} }
object[] o;
int scriptsStarted = 0;
while (m_CompileQueue.Dequeue(out o))
{
if (DoOnRezScript(o))
{
scriptsStarted++;
if (m_InitialStartup)
if (scriptsStarted % 50 == 0)
m_log.InfoFormat(
"[XEngine]: Started {0} scripts in {1}", scriptsStarted, m_Scene.Name);
}
}
if (m_InitialStartup)
m_log.InfoFormat(
"[XEngine]: Completed starting {0} scripts on {1}", scriptsStarted, m_Scene.Name);
} }
catch (Exception e)
{
m_log.Error(string.Format("[XEngine]: Failure in DoOnRezScriptQueue(). Exception ", e));
}
finally
{
// FIXME: On failure we must trigger this even if the compile queue is not actually empty so that the
// RegionReadyModule is not forever waiting. This event really needs a different name.
m_Scene.EventManager.TriggerEmptyScriptCompileQueue(m_ScriptFailCount,
m_ScriptErrorMessage);
if (m_InitialStartup) m_ScriptFailCount = 0;
m_log.InfoFormat( m_InitialStartup = false;
"[XEngine]: Completed starting {0} scripts on {1}", scriptsStarted, m_Scene.Name);
m_Scene.EventManager.TriggerEmptyScriptCompileQueue(m_ScriptFailCount, // NOTE: Despite having a lockless queue, this lock is required
m_ScriptErrorMessage); // to make sure there is never no compile thread while there
// are still scripts to compile. This could otherwise happen
m_ScriptFailCount = 0; // due to a race condition
m_InitialStartup = false; //
lock (m_CompileQueue)
// NOTE: Despite having a lockless queue, this lock is required m_CurrentCompile = null;
// to make sure there is never no compile thread while there }
// are still scripts to compile. This could otherwise happen
// due to a race condition
//
lock (m_CompileQueue)
m_CurrentCompile = null;
return null; return null;
} }