From 34d21ac94b227e0ab7c089000751e746ccf004a8 Mon Sep 17 00:00:00 2001 From: Tedd Hansen Date: Sat, 2 Feb 2008 00:09:55 +0000 Subject: Added some error checking to MaintenanceThread, no-crash (just log) loading of script engines, and support to load multiple script engines --- .../Common/ScriptEngineBase/MaintenanceThread.cs | 58 ++++++++++++---------- 1 file changed, 31 insertions(+), 27 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Common') diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/MaintenanceThread.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/MaintenanceThread.cs index 105d47f..842bac9 100644 --- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/MaintenanceThread.cs +++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/MaintenanceThread.cs @@ -95,40 +95,44 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase System.Threading.Thread.Sleep(MaintenanceLoopms); // Sleep before next pass if (PleaseShutdown) return; - // - // Re-reading config every x seconds - // - if (m_ScriptEngine.RefreshConfigFileSeconds > 0) + + if (m_ScriptEngine != null) { - // Check if its time to re-read config - if (DateTime.Now.Ticks - Last_ReReadConfigFilens > m_ScriptEngine.RefreshConfigFilens) + // + // Re-reading config every x seconds + // + if (m_ScriptEngine.RefreshConfigFileSeconds > 0) { - // Its time to re-read config file - m_ScriptEngine.ConfigSource.Reload(); // Refresh config - m_ScriptEngine.ReadConfig(); - Last_ReReadConfigFilens = DateTime.Now.Ticks; // Reset time + // Check if its time to re-read config + if (DateTime.Now.Ticks - Last_ReReadConfigFilens > m_ScriptEngine.RefreshConfigFilens) + { + // Its time to re-read config file + m_ScriptEngine.ReadConfig(); + Last_ReReadConfigFilens = DateTime.Now.Ticks; // Reset time + } } - } - // - // Adjust number of running script threads if not correct - // - m_ScriptEngine.m_EventQueueManager.AdjustNumberOfScriptThreads(); + // + // Adjust number of running script threads if not correct + // + if (m_ScriptEngine.m_EventQueueManager != null) + m_ScriptEngine.m_EventQueueManager.AdjustNumberOfScriptThreads(); - // - // Check if any script has exceeded its max execution time - // - if (m_ScriptEngine.m_EventQueueManager.EnforceMaxExecutionTime) - { - // We are enforcing execution time - if (DateTime.Now.Ticks - Last_maxFunctionExecutionTimens > - m_ScriptEngine.m_EventQueueManager.maxFunctionExecutionTimens) + // + // Check if any script has exceeded its max execution time + // + if (m_ScriptEngine.m_EventQueueManager != null && m_ScriptEngine.m_EventQueueManager.EnforceMaxExecutionTime) { - // Its time to check again - m_ScriptEngine.m_EventQueueManager.CheckScriptMaxExecTime(); // Do check - Last_maxFunctionExecutionTimens = DateTime.Now.Ticks; // Reset time + // We are enforcing execution time + if (DateTime.Now.Ticks - Last_maxFunctionExecutionTimens > + m_ScriptEngine.m_EventQueueManager.maxFunctionExecutionTimens) + { + // Its time to check again + m_ScriptEngine.m_EventQueueManager.CheckScriptMaxExecTime(); // Do check + Last_maxFunctionExecutionTimens = DateTime.Now.Ticks; // Reset time + } } - } + } // m_ScriptEngine != null } } catch (Exception ex) -- cgit v1.1