aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/MaintenanceThread.cs
diff options
context:
space:
mode:
authorTedd Hansen2008-02-01 23:36:36 +0000
committerTedd Hansen2008-02-01 23:36:36 +0000
commitd02a90823f2873f1b4de63062e3909d03a5a91fa (patch)
treecb0d8f79fd36bec98bbac39c1185ee40c75e7c6d /OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/MaintenanceThread.cs
parentSCRIPT SUPPORT IS STILL BROKEN. (diff)
downloadopensim-SC-d02a90823f2873f1b4de63062e3909d03a5a91fa.zip
opensim-SC-d02a90823f2873f1b4de63062e3909d03a5a91fa.tar.gz
opensim-SC-d02a90823f2873f1b4de63062e3909d03a5a91fa.tar.bz2
opensim-SC-d02a90823f2873f1b4de63062e3909d03a5a91fa.tar.xz
SCRIPTING STILL BROKEN
Added comments and regions, restructured code Changed a lot of AppDomain junk from console from using Console.Write to Log.Verbose and set it to #if DEBUG All modules should now refresh their configuration runtime Made all logging in ScriptEngine.Common get script name from actual engine Renamed LSLLongCmdHandler to AsyncLSLCommandManager Added auto-recover with 5 sec throttle for new MaintenanceThread
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/MaintenanceThread.cs')
-rw-r--r--OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/MaintenanceThread.cs86
1 files changed, 56 insertions, 30 deletions
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/MaintenanceThread.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/MaintenanceThread.cs
index 9536291..105d47f 100644
--- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/MaintenanceThread.cs
+++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/MaintenanceThread.cs
@@ -8,7 +8,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
8 /// <summary> 8 /// <summary>
9 /// This class does maintenance on script engine. 9 /// This class does maintenance on script engine.
10 /// </summary> 10 /// </summary>
11 public class MaintenanceThread 11 public class MaintenanceThread : iScriptEngineFunctionModule
12 { 12 {
13 public ScriptEngine m_ScriptEngine; 13 public ScriptEngine m_ScriptEngine;
14 private int MaintenanceLoopms; 14 private int MaintenanceLoopms;
@@ -28,7 +28,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
28 StopMaintenanceThread(); 28 StopMaintenanceThread();
29 } 29 }
30 30
31 private void ReadConfig() 31 public void ReadConfig()
32 { 32 {
33 MaintenanceLoopms = m_ScriptEngine.ScriptConfigSource.GetInt("MaintenanceLoopms", 50); 33 MaintenanceLoopms = m_ScriptEngine.ScriptConfigSource.GetInt("MaintenanceLoopms", 50);
34 } 34 }
@@ -80,48 +80,74 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
80 /// </summary> 80 /// </summary>
81 public void MaintenanceLoop() 81 public void MaintenanceLoop()
82 { 82 {
83 try 83 if (m_ScriptEngine.m_EventQueueManager.maxFunctionExecutionTimens < MaintenanceLoopms)
84 m_ScriptEngine.Log.Warn(m_ScriptEngine.ScriptEngineName,
85 "Configuration error: MaxEventExecutionTimeMs is less than MaintenanceLoopms. The Maintenance Loop will only check scripts once per run.");
86
87 while (true)
84 { 88 {
85 long Last_maxFunctionExecutionTimens = 0;// DateTime.Now.Ticks; 89 try
86 long Last_ReReadConfigFilens = DateTime.Now.Ticks;
87 while (true)
88 { 90 {
89 System.Threading.Thread.Sleep(MaintenanceLoopms); // Sleep 91 long Last_maxFunctionExecutionTimens = 0; // DateTime.Now.Ticks;
90 92 long Last_ReReadConfigFilens = DateTime.Now.Ticks;
91 // Re-reading config every x seconds? 93 while (true)
92 if (m_ScriptEngine.ReReadConfigFileSeconds > 0)
93 { 94 {
94 // Check if its time to re-read config 95 System.Threading.Thread.Sleep(MaintenanceLoopms); // Sleep before next pass
95 if (DateTime.Now.Ticks - Last_ReReadConfigFilens > m_ScriptEngine.ReReadConfigFilens) 96 if (PleaseShutdown)
97 return;
98 //
99 // Re-reading config every x seconds
100 //
101 if (m_ScriptEngine.RefreshConfigFileSeconds > 0)
96 { 102 {
97 // Its time to re-read config file 103 // Check if its time to re-read config
98 m_ScriptEngine.ConfigSource.Reload(); // Re-read config 104 if (DateTime.Now.Ticks - Last_ReReadConfigFilens > m_ScriptEngine.RefreshConfigFilens)
99 Last_ReReadConfigFilens = DateTime.Now.Ticks; // Reset time 105 {
106 // Its time to re-read config file
107 m_ScriptEngine.ConfigSource.Reload(); // Refresh config
108 m_ScriptEngine.ReadConfig();
109 Last_ReReadConfigFilens = DateTime.Now.Ticks; // Reset time
110 }
100 } 111 }
101 }
102 112
103 // Adjust number of running script threads if not correct 113 //
104 if (m_ScriptEngine.m_EventQueueManager.eventQueueThreads.Count != m_ScriptEngine.m_EventQueueManager.numberOfThreads) 114 // Adjust number of running script threads if not correct
105 { 115 //
106 m_ScriptEngine.m_EventQueueManager.AdjustNumberOfScriptThreads(); 116 m_ScriptEngine.m_EventQueueManager.AdjustNumberOfScriptThreads();
107 }
108
109 117
110 // Check if any script has exceeded its max execution time 118 //
111 if (m_ScriptEngine.m_EventQueueManager.EnforceMaxExecutionTime) 119 // Check if any script has exceeded its max execution time
112 { 120 //
113 if (DateTime.Now.Ticks - Last_maxFunctionExecutionTimens > m_ScriptEngine.m_EventQueueManager.maxFunctionExecutionTimens) 121 if (m_ScriptEngine.m_EventQueueManager.EnforceMaxExecutionTime)
114 { 122 {
115 m_ScriptEngine.m_EventQueueManager.CheckScriptMaxExecTime(); // Do check 123 // We are enforcing execution time
116 Last_maxFunctionExecutionTimens = DateTime.Now.Ticks; // Reset time 124 if (DateTime.Now.Ticks - Last_maxFunctionExecutionTimens >
125 m_ScriptEngine.m_EventQueueManager.maxFunctionExecutionTimens)
126 {
127 // Its time to check again
128 m_ScriptEngine.m_EventQueueManager.CheckScriptMaxExecTime(); // Do check
129 Last_maxFunctionExecutionTimens = DateTime.Now.Ticks; // Reset time
130 }
117 } 131 }
118 } 132 }
119 } 133 }
120 } 134 catch (Exception ex)
121 catch (ThreadAbortException tae) 135 {
122 { 136 m_ScriptEngine.Log.Error(m_ScriptEngine.ScriptEngineName, "Exception in MaintenanceLoopThread. Thread will recover after 5 sec throttle. Exception: " + ex.ToString());
137 Thread.Sleep(5000);
138 }
123 } 139 }
124 } 140 }
125 #endregion 141 #endregion
142 /// <summary>
143 /// If set to true then threads and stuff should try to make a graceful exit
144 /// </summary>
145 public bool PleaseShutdown
146 {
147 get { return _PleaseShutdown; }
148 set { _PleaseShutdown = value; }
149 }
150 private bool _PleaseShutdown = false;
151
126 } 152 }
127} 153}