aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/DotNetEngine/MaintenanceThread.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine/DotNetEngine/MaintenanceThread.cs')
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/MaintenanceThread.cs83
1 files changed, 40 insertions, 43 deletions
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/MaintenanceThread.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/MaintenanceThread.cs
index 7ffdb1a..87fdf1f 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/MaintenanceThread.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/MaintenanceThread.cs
@@ -93,10 +93,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
93 { 93 {
94 if (MaintenanceThreadThread == null) 94 if (MaintenanceThreadThread == null)
95 { 95 {
96 MaintenanceThreadThread = new Thread(MaintenanceLoop); 96 MaintenanceThreadThread = Watchdog.StartThread(MaintenanceLoop, "ScriptMaintenanceThread", ThreadPriority.Normal, true);
97 MaintenanceThreadThread.Name = "ScriptMaintenanceThread";
98 MaintenanceThreadThread.IsBackground = true;
99 MaintenanceThreadThread.Start();
100 } 97 }
101 } 98 }
102 99
@@ -164,56 +161,54 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
164 MaintenanceLoopTicks_ScriptLoadUnload_Count++; 161 MaintenanceLoopTicks_ScriptLoadUnload_Count++;
165 MaintenanceLoopTicks_Other_Count++; 162 MaintenanceLoopTicks_Other_Count++;
166 163
167 164 foreach (ScriptEngine m_ScriptEngine in new ArrayList(ScriptEngine.ScriptEngines))
168 //lock (ScriptEngine.ScriptEngines) 165 {
169 //{ 166 // lastScriptEngine = m_ScriptEngine;
170 foreach (ScriptEngine m_ScriptEngine in new ArrayList(ScriptEngine.ScriptEngines)) 167 // Re-reading config every x seconds
168 if (MaintenanceLoopTicks_Other_Count >= MaintenanceLoopTicks_Other)
171 { 169 {
172 // lastScriptEngine = m_ScriptEngine; 170 MaintenanceLoopTicks_Other_ResetCount = true;
173 // Re-reading config every x seconds 171 if (m_ScriptEngine.RefreshConfigFilens > 0)
174 if (MaintenanceLoopTicks_Other_Count >= MaintenanceLoopTicks_Other)
175 { 172 {
176 MaintenanceLoopTicks_Other_ResetCount = true; 173 // Check if its time to re-read config
177 if (m_ScriptEngine.RefreshConfigFilens > 0) 174 if (DateTime.Now.Ticks - Last_ReReadConfigFilens >
175 m_ScriptEngine.RefreshConfigFilens)
178 { 176 {
179 // Check if its time to re-read config 177 //m_log.Debug("Time passed: " + (DateTime.Now.Ticks - Last_ReReadConfigFilens) + ">" + m_ScriptEngine.RefreshConfigFilens);
180 if (DateTime.Now.Ticks - Last_ReReadConfigFilens > 178 // Its time to re-read config file
181 m_ScriptEngine.RefreshConfigFilens) 179 m_ScriptEngine.ReadConfig();
182 { 180 Last_ReReadConfigFilens = DateTime.Now.Ticks; // Reset time
183 //m_log.Debug("Time passed: " + (DateTime.Now.Ticks - Last_ReReadConfigFilens) + ">" + m_ScriptEngine.RefreshConfigFilens); 181 }
184 // Its time to re-read config file
185 m_ScriptEngine.ReadConfig();
186 Last_ReReadConfigFilens = DateTime.Now.Ticks; // Reset time
187 }
188 182
189 183
190 // Adjust number of running script threads if not correct 184 // Adjust number of running script threads if not correct
191 if (m_ScriptEngine.m_EventQueueManager != null) 185 if (m_ScriptEngine.m_EventQueueManager != null)
192 m_ScriptEngine.m_EventQueueManager.AdjustNumberOfScriptThreads(); 186 m_ScriptEngine.m_EventQueueManager.AdjustNumberOfScriptThreads();
193 187
194 // Check if any script has exceeded its max execution time 188 // Check if any script has exceeded its max execution time
195 if (EventQueueManager.EnforceMaxExecutionTime) 189 if (EventQueueManager.EnforceMaxExecutionTime)
190 {
191 // We are enforcing execution time
192 if (DateTime.Now.Ticks - Last_maxFunctionExecutionTimens >
193 EventQueueManager.maxFunctionExecutionTimens)
196 { 194 {
197 // We are enforcing execution time 195 // Its time to check again
198 if (DateTime.Now.Ticks - Last_maxFunctionExecutionTimens > 196 m_ScriptEngine.m_EventQueueManager.CheckScriptMaxExecTime(); // Do check
199 EventQueueManager.maxFunctionExecutionTimens) 197 Last_maxFunctionExecutionTimens = DateTime.Now.Ticks; // Reset time
200 {
201 // Its time to check again
202 m_ScriptEngine.m_EventQueueManager.CheckScriptMaxExecTime(); // Do check
203 Last_maxFunctionExecutionTimens = DateTime.Now.Ticks; // Reset time
204 }
205 } 198 }
206 } 199 }
207 } 200 }
208 if (MaintenanceLoopTicks_ScriptLoadUnload_Count >= MaintenanceLoopTicks_ScriptLoadUnload)
209 {
210 MaintenanceLoopTicks_ScriptLoadUnload_ResetCount = true;
211 // LOAD / UNLOAD SCRIPTS
212 if (m_ScriptEngine.m_ScriptManager != null)
213 m_ScriptEngine.m_ScriptManager.DoScriptLoadUnload();
214 }
215 } 201 }
216 //} 202 if (MaintenanceLoopTicks_ScriptLoadUnload_Count >= MaintenanceLoopTicks_ScriptLoadUnload)
203 {
204 MaintenanceLoopTicks_ScriptLoadUnload_ResetCount = true;
205 // LOAD / UNLOAD SCRIPTS
206 if (m_ScriptEngine.m_ScriptManager != null)
207 m_ScriptEngine.m_ScriptManager.DoScriptLoadUnload();
208 }
209 }
210
211 Watchdog.UpdateThread();
217 } 212 }
218 } 213 }
219 catch(ThreadAbortException) 214 catch(ThreadAbortException)
@@ -225,6 +220,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
225 m_log.ErrorFormat("Exception in MaintenanceLoopThread. Thread will recover after 5 sec throttle. Exception: {0}", ex.ToString()); 220 m_log.ErrorFormat("Exception in MaintenanceLoopThread. Thread will recover after 5 sec throttle. Exception: {0}", ex.ToString());
226 } 221 }
227 } 222 }
223
224 Watchdog.RemoveThread();
228 } 225 }
229 #endregion 226 #endregion
230 227