aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/MaintenanceThread.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/MaintenanceThread.cs')
-rw-r--r--OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/MaintenanceThread.cs86
1 files changed, 46 insertions, 40 deletions
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/MaintenanceThread.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/MaintenanceThread.cs
index e0ec27f..eb57a9e 100644
--- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/MaintenanceThread.cs
+++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/MaintenanceThread.cs
@@ -63,13 +63,18 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
63 public void ReadConfig() 63 public void ReadConfig()
64 { 64 {
65 // Bad hack, but we need a m_ScriptEngine :) 65 // Bad hack, but we need a m_ScriptEngine :)
66 foreach (ScriptEngine m_ScriptEngine in ScriptEngine.ScriptEngines) 66 lock (ScriptEngine.ScriptEngines)
67 { 67 {
68 MaintenanceLoopms = m_ScriptEngine.ScriptConfigSource.GetInt("MaintenanceLoopms", 50); 68 foreach (ScriptEngine m_ScriptEngine in ScriptEngine.ScriptEngines)
69 MaintenanceLoopTicks_ScriptLoadUnload = m_ScriptEngine.ScriptConfigSource.GetInt("MaintenanceLoopTicks_ScriptLoadUnload", 1); 69 {
70 MaintenanceLoopTicks_Other = m_ScriptEngine.ScriptConfigSource.GetInt("MaintenanceLoopTicks_Other", 10); 70 MaintenanceLoopms = m_ScriptEngine.ScriptConfigSource.GetInt("MaintenanceLoopms", 50);
71 MaintenanceLoopTicks_ScriptLoadUnload =
72 m_ScriptEngine.ScriptConfigSource.GetInt("MaintenanceLoopTicks_ScriptLoadUnload", 1);
73 MaintenanceLoopTicks_Other =
74 m_ScriptEngine.ScriptConfigSource.GetInt("MaintenanceLoopTicks_Other", 10);
71 75
72 return; 76 return;
77 }
73 } 78 }
74 } 79 }
75 80
@@ -159,52 +164,53 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
159 MaintenanceLoopTicks_Other_Count++; 164 MaintenanceLoopTicks_Other_Count++;
160 165
161 166
162 foreach (ScriptEngine m_ScriptEngine in new ArrayList(ScriptEngine.ScriptEngines)) 167 lock (ScriptEngine.ScriptEngines)
163 { 168 {
164 lastScriptEngine = m_ScriptEngine; 169 foreach (ScriptEngine m_ScriptEngine in ScriptEngine.ScriptEngines)
165 // Re-reading config every x seconds
166 if (MaintenanceLoopTicks_Other_Count >= MaintenanceLoopTicks_Other)
167 { 170 {
168 MaintenanceLoopTicks_Other_ResetCount = true; 171 lastScriptEngine = m_ScriptEngine;
169 if (m_ScriptEngine.RefreshConfigFilens > 0) 172 // Re-reading config every x seconds
173 if (MaintenanceLoopTicks_Other_Count >= MaintenanceLoopTicks_Other)
170 { 174 {
171 175 MaintenanceLoopTicks_Other_ResetCount = true;
172 // Check if its time to re-read config 176 if (m_ScriptEngine.RefreshConfigFilens > 0)
173 if (DateTime.Now.Ticks - Last_ReReadConfigFilens >
174 m_ScriptEngine.RefreshConfigFilens)
175 { 177 {
176 //Console.WriteLine("Time passed: " + (DateTime.Now.Ticks - Last_ReReadConfigFilens) + ">" + m_ScriptEngine.RefreshConfigFilens ); 178 // Check if its time to re-read config
177 // Its time to re-read config file 179 if (DateTime.Now.Ticks - Last_ReReadConfigFilens >
178 m_ScriptEngine.ReadConfig(); 180 m_ScriptEngine.RefreshConfigFilens)
179 Last_ReReadConfigFilens = DateTime.Now.Ticks; // Reset time 181 {
180 } 182 //Console.WriteLine("Time passed: " + (DateTime.Now.Ticks - Last_ReReadConfigFilens) + ">" + m_ScriptEngine.RefreshConfigFilens );
183 // Its time to re-read config file
184 m_ScriptEngine.ReadConfig();
185 Last_ReReadConfigFilens = DateTime.Now.Ticks; // Reset time
186 }
181 187
182 188
183 // Adjust number of running script threads if not correct 189 // Adjust number of running script threads if not correct
184 if (m_ScriptEngine.m_EventQueueManager != null) 190 if (m_ScriptEngine.m_EventQueueManager != null)
185 m_ScriptEngine.m_EventQueueManager.AdjustNumberOfScriptThreads(); 191 m_ScriptEngine.m_EventQueueManager.AdjustNumberOfScriptThreads();
186 192
187 // Check if any script has exceeded its max execution time 193 // Check if any script has exceeded its max execution time
188 if (EventQueueManager.EnforceMaxExecutionTime) 194 if (EventQueueManager.EnforceMaxExecutionTime)
189 {
190 // We are enforcing execution time
191 if (DateTime.Now.Ticks - Last_maxFunctionExecutionTimens >
192 EventQueueManager.maxFunctionExecutionTimens)
193 { 195 {
194 // Its time to check again 196 // We are enforcing execution time
195 m_ScriptEngine.m_EventQueueManager.CheckScriptMaxExecTime(); // Do check 197 if (DateTime.Now.Ticks - Last_maxFunctionExecutionTimens >
196 Last_maxFunctionExecutionTimens = DateTime.Now.Ticks; // Reset time 198 EventQueueManager.maxFunctionExecutionTimens)
199 {
200 // Its time to check again
201 m_ScriptEngine.m_EventQueueManager.CheckScriptMaxExecTime(); // Do check
202 Last_maxFunctionExecutionTimens = DateTime.Now.Ticks; // Reset time
203 }
197 } 204 }
198 } 205 }
199 } 206 }
200 207 if (MaintenanceLoopTicks_ScriptLoadUnload_Count >= MaintenanceLoopTicks_ScriptLoadUnload)
201 } 208 {
202 if (MaintenanceLoopTicks_ScriptLoadUnload_Count >= MaintenanceLoopTicks_ScriptLoadUnload) 209 MaintenanceLoopTicks_ScriptLoadUnload_ResetCount = true;
203 { 210 // LOAD / UNLOAD SCRIPTS
204 MaintenanceLoopTicks_ScriptLoadUnload_ResetCount = true; 211 if (m_ScriptEngine.m_ScriptManager != null)
205 // LOAD / UNLOAD SCRIPTS 212 m_ScriptEngine.m_ScriptManager.DoScriptLoadUnload();
206 if (m_ScriptEngine.m_ScriptManager != null) 213 }
207 m_ScriptEngine.m_ScriptManager.DoScriptLoadUnload();
208 } 214 }
209 } 215 }
210 } 216 }