aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueManager.cs18
-rw-r--r--OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/MaintenanceThread.cs71
-rw-r--r--OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptEngine.cs26
-rw-r--r--OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptManager.cs49
-rw-r--r--OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/iScriptEngineFunctionModule.cs2
5 files changed, 87 insertions, 79 deletions
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueManager.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueManager.cs
index aa7e3e9..e3d448c 100644
--- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueManager.cs
+++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueManager.cs
@@ -452,14 +452,14 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
452 } 452 }
453 #endregion 453 #endregion
454 454
455 /// <summary> 455 ///// <summary>
456 /// If set to true then threads and stuff should try to make a graceful exit 456 ///// If set to true then threads and stuff should try to make a graceful exit
457 /// </summary> 457 ///// </summary>
458 public bool PleaseShutdown 458 //public bool PleaseShutdown
459 { 459 //{
460 get { return _PleaseShutdown; } 460 // get { return _PleaseShutdown; }
461 set { _PleaseShutdown = value; } 461 // set { _PleaseShutdown = value; }
462 } 462 //}
463 private bool _PleaseShutdown = false; 463 //private bool _PleaseShutdown = false;
464 } 464 }
465} 465}
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/MaintenanceThread.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/MaintenanceThread.cs
index f959a5b..1a5cca1 100644
--- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/MaintenanceThread.cs
+++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/MaintenanceThread.cs
@@ -38,12 +38,12 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
38 /// </summary> 38 /// </summary>
39 public class MaintenanceThread : iScriptEngineFunctionModule 39 public class MaintenanceThread : iScriptEngineFunctionModule
40 { 40 {
41 public ScriptEngine m_ScriptEngine; 41 //public ScriptEngine m_ScriptEngine;
42 private int MaintenanceLoopms; 42 private int MaintenanceLoopms;
43 43
44 public MaintenanceThread(ScriptEngine _ScriptEngine) 44 public MaintenanceThread()
45 { 45 {
46 m_ScriptEngine = _ScriptEngine; 46 //m_ScriptEngine = _ScriptEngine;
47 47
48 ReadConfig(); 48 ReadConfig();
49 49
@@ -95,9 +95,9 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
95 try 95 try
96 { 96 {
97 if (MaintenanceThreadThread != null && MaintenanceThreadThread.IsAlive) 97 if (MaintenanceThreadThread != null && MaintenanceThreadThread.IsAlive)
98 { 98 {
99 MaintenanceThreadThread.Abort(); 99 MaintenanceThreadThread.Abort();
100 } 100 }
101 } 101 }
102 catch (Exception ex) 102 catch (Exception ex)
103 { 103 {
@@ -105,14 +105,15 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
105 } 105 }
106 } 106 }
107 107
108 private ScriptEngine lastScriptEngine; // Keep track of what ScriptEngine instance we are at so we can give exception
108 /// <summary> 109 /// <summary>
109 /// A thread should run in this loop and check all running scripts 110 /// A thread should run in this loop and check all running scripts
110 /// </summary> 111 /// </summary>
111 public void MaintenanceLoop() 112 public void MaintenanceLoop()
112 { 113 {
113 if (m_ScriptEngine.m_EventQueueManager.maxFunctionExecutionTimens < MaintenanceLoopms) 114 //if (m_ScriptEngine.m_EventQueueManager.maxFunctionExecutionTimens < MaintenanceLoopms)
114 m_ScriptEngine.Log.Warn("[" + m_ScriptEngine.ScriptEngineName + "]: " + 115 // m_ScriptEngine.Log.Warn("[" + m_ScriptEngine.ScriptEngineName + "]: " +
115 "Configuration error: MaxEventExecutionTimeMs is less than MaintenanceLoopms. The Maintenance Loop will only check scripts once per run."); 116 // "Configuration error: MaxEventExecutionTimeMs is less than MaintenanceLoopms. The Maintenance Loop will only check scripts once per run.");
116 117
117 long Last_maxFunctionExecutionTimens = 0; // DateTime.Now.Ticks; 118 long Last_maxFunctionExecutionTimens = 0; // DateTime.Now.Ticks;
118 long Last_ReReadConfigFilens = DateTime.Now.Ticks; 119 long Last_ReReadConfigFilens = DateTime.Now.Ticks;
@@ -126,35 +127,41 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
126 if (PleaseShutdown) 127 if (PleaseShutdown)
127 return; 128 return;
128 129
129 if (m_ScriptEngine != null) 130 foreach (ScriptEngine m_ScriptEngine in ScriptEngine.ScriptEngines)
130 { 131 {
131 // Re-reading config every x seconds 132 lastScriptEngine = m_ScriptEngine;
132 if (m_ScriptEngine.RefreshConfigFilens > 0) 133 if (m_ScriptEngine != null)
133 { 134 {
134 // Check if its time to re-read config 135 // Re-reading config every x seconds
135 if (DateTime.Now.Ticks - Last_ReReadConfigFilens > m_ScriptEngine.RefreshConfigFilens) 136 if (m_ScriptEngine.RefreshConfigFilens > 0)
136 { 137 {
137 //Console.WriteLine("Time passed: " + (DateTime.Now.Ticks - Last_ReReadConfigFilens) + ">" + m_ScriptEngine.RefreshConfigFilens ); 138 // Check if its time to re-read config
138 // Its time to re-read config file 139 if (DateTime.Now.Ticks - Last_ReReadConfigFilens >
139 m_ScriptEngine.ReadConfig(); 140 m_ScriptEngine.RefreshConfigFilens)
140 Last_ReReadConfigFilens = DateTime.Now.Ticks; // Reset time 141 {
142 //Console.WriteLine("Time passed: " + (DateTime.Now.Ticks - Last_ReReadConfigFilens) + ">" + m_ScriptEngine.RefreshConfigFilens );
143 // Its time to re-read config file
144 m_ScriptEngine.ReadConfig();
145 Last_ReReadConfigFilens = DateTime.Now.Ticks; // Reset time
146 }
141 } 147 }
142 }
143 148
144 // Adjust number of running script threads if not correct 149 // Adjust number of running script threads if not correct
145 if (m_ScriptEngine.m_EventQueueManager != null) 150 if (m_ScriptEngine.m_EventQueueManager != null)
146 m_ScriptEngine.m_EventQueueManager.AdjustNumberOfScriptThreads(); 151 m_ScriptEngine.m_EventQueueManager.AdjustNumberOfScriptThreads();
147 152
148 // Check if any script has exceeded its max execution time 153 // Check if any script has exceeded its max execution time
149 if (m_ScriptEngine.m_EventQueueManager != null && m_ScriptEngine.m_EventQueueManager.EnforceMaxExecutionTime) 154 if (m_ScriptEngine.m_EventQueueManager != null &&
150 { 155 m_ScriptEngine.m_EventQueueManager.EnforceMaxExecutionTime)
151 // We are enforcing execution time
152 if (DateTime.Now.Ticks - Last_maxFunctionExecutionTimens >
153 m_ScriptEngine.m_EventQueueManager.maxFunctionExecutionTimens)
154 { 156 {
155 // Its time to check again 157 // We are enforcing execution time
156 m_ScriptEngine.m_EventQueueManager.CheckScriptMaxExecTime(); // Do check 158 if (DateTime.Now.Ticks - Last_maxFunctionExecutionTimens >
157 Last_maxFunctionExecutionTimens = DateTime.Now.Ticks; // Reset time 159 m_ScriptEngine.m_EventQueueManager.maxFunctionExecutionTimens)
160 {
161 // Its time to check again
162 m_ScriptEngine.m_EventQueueManager.CheckScriptMaxExecTime(); // Do check
163 Last_maxFunctionExecutionTimens = DateTime.Now.Ticks; // Reset time
164 }
158 } 165 }
159 } 166 }
160 } 167 }
@@ -162,7 +169,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
162 } 169 }
163 catch (Exception ex) 170 catch (Exception ex)
164 { 171 {
165 m_ScriptEngine.Log.Error("[" + m_ScriptEngine.ScriptEngineName + "]: Exception in MaintenanceLoopThread. Thread will recover after 5 sec throttle. Exception: " + ex.ToString()); 172 ScriptEngine.Log.Error("[" + lastScriptEngine.ScriptEngineName + "]: Exception in MaintenanceLoopThread. Thread will recover after 5 sec throttle. Exception: " + ex.ToString());
166 Thread.Sleep(5000); 173 Thread.Sleep(5000);
167 } 174 }
168 } 175 }
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptEngine.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptEngine.cs
index 3777b67..67eefd9 100644
--- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptEngine.cs
+++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptEngine.cs
@@ -27,6 +27,7 @@
27*/ 27*/
28 28
29using System; 29using System;
30using System.Collections.Generic;
30using System.IO; 31using System.IO;
31using Nini.Config; 32using Nini.Config;
32using OpenSim.Framework.Console; 33using OpenSim.Framework.Console;
@@ -46,13 +47,14 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
46 { 47 {
47 private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); 48 private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
48 49
50 public static List<ScriptEngine> ScriptEngines = new List<ScriptEngine>();
49 public Scene World; 51 public Scene World;
50 public EventManager m_EventManager; // Handles and queues incoming events from OpenSim 52 public EventManager m_EventManager; // Handles and queues incoming events from OpenSim
51 public EventQueueManager m_EventQueueManager; // Executes events, handles script threads 53 public EventQueueManager m_EventQueueManager; // Executes events, handles script threads
52 public ScriptManager m_ScriptManager; // Load, unload and execute scripts 54 public ScriptManager m_ScriptManager; // Load, unload and execute scripts
53 public AppDomainManager m_AppDomainManager; // Handles loading/unloading of scripts into AppDomains 55 public AppDomainManager m_AppDomainManager; // Handles loading/unloading of scripts into AppDomains
54 public AsyncLSLCommandManager m_ASYNCLSLCommandManager; // Asyncronous LSL commands (commands that returns with an event) 56 public AsyncLSLCommandManager m_ASYNCLSLCommandManager; // Asyncronous LSL commands (commands that returns with an event)
55 public MaintenanceThread m_MaintenanceThread; // Thread that does different kinds of maintenance, for example refreshing config and killing scripts that has been running too long 57 public static MaintenanceThread m_MaintenanceThread; // Thread that does different kinds of maintenance, for example refreshing config and killing scripts that has been running too long
56 58
57 public IConfigSource ConfigSource; 59 public IConfigSource ConfigSource;
58 public IConfig ScriptConfigSource; 60 public IConfig ScriptConfigSource;
@@ -74,15 +76,15 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
74 76
75 public abstract ScriptManager _GetScriptManager(); 77 public abstract ScriptManager _GetScriptManager();
76 78
77 public log4net.ILog Log 79 public static log4net.ILog Log
78 { 80 {
79 get { return m_log; } 81 get { return m_log; }
80 } 82 }
81 83
82 public ScriptEngine() 84 public ScriptEngine()
83 { 85 {
84 //Common.SendToDebug("ScriptEngine Object Initialized"); 86 Common.mySE = this; // For logging, just need any instance, doesn't matter
85 Common.mySE = this; 87 ScriptEngines.Add(this); // Keep a list of ScriptEngines for shared threads to process all instances
86 } 88 }
87 89
88 public void InitializeEngine(Scene Sceneworld, IConfigSource config, bool HookUpToServer, ScriptManager newScriptManager) 90 public void InitializeEngine(Scene Sceneworld, IConfigSource config, bool HookUpToServer, ScriptManager newScriptManager)
@@ -106,7 +108,8 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
106 m_ScriptManager = newScriptManager; 108 m_ScriptManager = newScriptManager;
107 m_AppDomainManager = new AppDomainManager(this); 109 m_AppDomainManager = new AppDomainManager(this);
108 m_ASYNCLSLCommandManager = new AsyncLSLCommandManager(this); 110 m_ASYNCLSLCommandManager = new AsyncLSLCommandManager(this);
109 m_MaintenanceThread = new MaintenanceThread(this); 111 if (m_MaintenanceThread == null)
112 m_MaintenanceThread = new MaintenanceThread();
110 113
111 m_log.Info("[" + ScriptEngineName + "]: Reading configuration from config section \"" + ScriptEngineName + "\""); 114 m_log.Info("[" + ScriptEngineName + "]: Reading configuration from config section \"" + ScriptEngineName + "\"");
112 ReadConfig(); 115 ReadConfig();
@@ -118,6 +121,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
118 public void Shutdown() 121 public void Shutdown()
119 { 122 {
120 // We are shutting down 123 // We are shutting down
124 ScriptEngines.Remove(this);
121 } 125 }
122 126
123 ScriptServerInterfaces.RemoteEvents ScriptServerInterfaces.ScriptEngine.EventManager() 127 ScriptServerInterfaces.RemoteEvents ScriptServerInterfaces.ScriptEngine.EventManager()
@@ -178,12 +182,12 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
178 /// <summary> 182 /// <summary>
179 /// If set to true then threads and stuff should try to make a graceful exit 183 /// If set to true then threads and stuff should try to make a graceful exit
180 /// </summary> 184 /// </summary>
181 public bool PleaseShutdown 185 //public bool PleaseShutdown
182 { 186 //{
183 get { return _PleaseShutdown; } 187 // get { return _PleaseShutdown; }
184 set { _PleaseShutdown = value; } 188 // set { _PleaseShutdown = value; }
185 } 189 //}
186 private bool _PleaseShutdown = false; 190 //private bool _PleaseShutdown = false;
187 191
188 } 192 }
189} 193}
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptManager.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptManager.cs
index 684d133..b50c184 100644
--- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptManager.cs
+++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptManager.cs
@@ -169,15 +169,12 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
169 // Abort load/unload thread 169 // Abort load/unload thread
170 try 170 try
171 { 171 {
172 PleaseShutdown = true; 172 //PleaseShutdown = true;
173 Thread.Sleep(100); 173 //Thread.Sleep(100);
174 if (scriptLoadUnloadThread != null) 174 if (scriptLoadUnloadThread != null && scriptLoadUnloadThread.IsAlive == true)
175 { 175 {
176 if (scriptLoadUnloadThread.IsAlive == true) 176 scriptLoadUnloadThread.Abort();
177 { 177 //scriptLoadUnloadThread.Join();
178 scriptLoadUnloadThread.Abort();
179 scriptLoadUnloadThread.Join();
180 }
181 } 178 }
182 } 179 }
183 catch 180 catch
@@ -282,7 +279,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
282 279
283 public abstract void _StartScript(uint localID, LLUUID itemID, string Script); 280 public abstract void _StartScript(uint localID, LLUUID itemID, string Script);
284 public abstract void _StopScript(uint localID, LLUUID itemID); 281 public abstract void _StopScript(uint localID, LLUUID itemID);
285 282
286 283
287 #endregion 284 #endregion
288 285
@@ -297,10 +294,10 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
297 /// <param name="args">Arguments to pass to function</param> 294 /// <param name="args">Arguments to pass to function</param>
298 internal void ExecuteEvent(uint localID, LLUUID itemID, string FunctionName, EventQueueManager.Queue_llDetectParams_Struct qParams, object[] args) 295 internal void ExecuteEvent(uint localID, LLUUID itemID, string FunctionName, EventQueueManager.Queue_llDetectParams_Struct qParams, object[] args)
299 { 296 {
300//cfk 2-7-08 dont need this right now and the default Linux build has DEBUG defined 297 //cfk 2-7-08 dont need this right now and the default Linux build has DEBUG defined
301///#if DEBUG 298 ///#if DEBUG
302/// Console.WriteLine("ScriptEngine: Inside ExecuteEvent for event " + FunctionName); 299 /// Console.WriteLine("ScriptEngine: Inside ExecuteEvent for event " + FunctionName);
303///#endif 300 ///#endif
304 // Execute a function in the script 301 // Execute a function in the script
305 //m_scriptEngine.Log.Info("[" + ScriptEngineName + "]: Executing Function localID: " + localID + ", itemID: " + itemID + ", FunctionName: " + FunctionName); 302 //m_scriptEngine.Log.Info("[" + ScriptEngineName + "]: Executing Function localID: " + localID + ", itemID: " + itemID + ", FunctionName: " + FunctionName);
306 //ScriptBaseInterface Script = (ScriptBaseInterface)GetScript(localID, itemID); 303 //ScriptBaseInterface Script = (ScriptBaseInterface)GetScript(localID, itemID);
@@ -309,10 +306,10 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
309 { 306 {
310 return; 307 return;
311 } 308 }
312//cfk 2-7-08 dont need this right now and the default Linux build has DEBUG defined 309 //cfk 2-7-08 dont need this right now and the default Linux build has DEBUG defined
313///#if DEBUG 310 ///#if DEBUG
314/// Console.WriteLine("ScriptEngine: Executing event: " + FunctionName); 311 /// Console.WriteLine("ScriptEngine: Executing event: " + FunctionName);
315///#endif 312 ///#endif
316 // Must be done in correct AppDomain, so leaving it up to the script itself 313 // Must be done in correct AppDomain, so leaving it up to the script itself
317 Script.llDetectParams = qParams; 314 Script.llDetectParams = qParams;
318 Script.Exec.ExecuteEvent(FunctionName, args); 315 Script.Exec.ExecuteEvent(FunctionName, args);
@@ -418,15 +415,15 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
418 415
419 #endregion 416 #endregion
420 417
421 /// <summary> 418 ///// <summary>
422 /// If set to true then threads and stuff should try to make a graceful exit 419 ///// If set to true then threads and stuff should try to make a graceful exit
423 /// </summary> 420 ///// </summary>
424 public bool PleaseShutdown 421 //public bool PleaseShutdown
425 { 422 //{
426 get { return _PleaseShutdown; } 423 // get { return _PleaseShutdown; }
427 set { _PleaseShutdown = value; } 424 // set { _PleaseShutdown = value; }
428 } 425 //}
429 private bool _PleaseShutdown = false; 426 //private bool _PleaseShutdown = false;
430 427
431 } 428 }
432} 429}
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/iScriptEngineFunctionModule.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/iScriptEngineFunctionModule.cs
index 1c730f5..516d76a 100644
--- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/iScriptEngineFunctionModule.cs
+++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/iScriptEngineFunctionModule.cs
@@ -35,6 +35,6 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
35 public interface iScriptEngineFunctionModule 35 public interface iScriptEngineFunctionModule
36 { 36 {
37 void ReadConfig(); 37 void ReadConfig();
38 bool PleaseShutdown { get; set; } 38// bool PleaseShutdown { get; set; }
39 } 39 }
40} \ No newline at end of file 40} \ No newline at end of file