aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine')
-rw-r--r--OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueManager.cs32
-rw-r--r--OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueThreadClass.cs14
2 files changed, 22 insertions, 24 deletions
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueManager.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueManager.cs
index 267cf52..eaffe3f 100644
--- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueManager.cs
+++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueManager.cs
@@ -60,24 +60,22 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
60 // Notes: 60 // Notes:
61 // * Current execution load balancing is optimized for 1 thread, and can cause unfair execute balancing between scripts. 61 // * Current execution load balancing is optimized for 1 thread, and can cause unfair execute balancing between scripts.
62 // Not noticeable unless server is under high load. 62 // Not noticeable unless server is under high load.
63 // * This class contains the number of threads used for script executions. Since we are not microthreading scripts yet,
64 // increase number of threads to allow more concurrent script executions in OpenSim.
65 // 63 //
66 64
67 public ScriptEngine m_ScriptEngine; 65 public ScriptEngine m_ScriptEngine;
68 66
69 /// <summary> 67 /// <summary>
70 /// List of threads (classes) processing event queue 68 /// List of threads (classes) processing event queue
69 /// Note that this may or may not be a reference to a static object depending on PrivateRegionThreads config setting.
71 /// </summary> 70 /// </summary>
72 internal List<EventQueueThreadClass> eventQueueThreads; // Thread pool that we work on 71 internal List<EventQueueThreadClass> eventQueueThreads; // Thread pool that we work on
73 /// <summary> 72 /// <summary>
74 /// Locking access to eventQueueThreads AND staticGlobalEventQueueThreads. 73 /// Locking access to eventQueueThreads AND staticGlobalEventQueueThreads.
75 /// Note that this may or may not be a reference to a static object depending on PrivateRegionThreads config setting.
76 /// </summary> 74 /// </summary>
77 private object eventQueueThreadsLock = new object(); 75// private object eventQueueThreadsLock = new object();
78 // Static objects for referencing the objects above if we don't have private threads: 76 // Static objects for referencing the objects above if we don't have private threads:
79 internal static List<EventQueueThreadClass> staticEventQueueThreads; // A static reference used if we don't use private threads 77 internal static List<EventQueueThreadClass> staticEventQueueThreads; // A static reference used if we don't use private threads
80 internal static object staticEventQueueThreadsLock; // Statick lock object reference for same reason 78// internal static object staticEventQueueThreadsLock; // Statick lock object reference for same reason
81 79
82 /// <summary> 80 /// <summary>
83 /// Global static list of all threads (classes) processing event queue -- used by max enforcment thread 81 /// Global static list of all threads (classes) processing event queue -- used by max enforcment thread
@@ -91,7 +89,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
91 public object ThreadsToExitLock = new object(); 89 public object ThreadsToExitLock = new object();
92 90
93 91
94 public object queueLock = new object(); // Mutex lock object 92 //public object queueLock = new object(); // Mutex lock object
95 93
96 /// <summary> 94 /// <summary>
97 /// How many threads to process queue with 95 /// How many threads to process queue with
@@ -183,7 +181,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
183 { 181 {
184 // PRIVATE THREAD POOL PER REGION 182 // PRIVATE THREAD POOL PER REGION
185 eventQueueThreads = new List<EventQueueThreadClass>(); 183 eventQueueThreads = new List<EventQueueThreadClass>();
186 eventQueueThreadsLock = new object(); 184 // eventQueueThreadsLock = new object();
187 } 185 }
188 else 186 else
189 { 187 {
@@ -191,12 +189,12 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
191 // Crate the static objects 189 // Crate the static objects
192 if (staticEventQueueThreads == null) 190 if (staticEventQueueThreads == null)
193 staticEventQueueThreads = new List<EventQueueThreadClass>(); 191 staticEventQueueThreads = new List<EventQueueThreadClass>();
194 if (staticEventQueueThreadsLock == null) 192 // if (staticEventQueueThreadsLock == null)
195 staticEventQueueThreadsLock = new object(); 193 // staticEventQueueThreadsLock = new object();
196 194
197 // Now reference our locals to them 195 // Now reference our locals to them
198 eventQueueThreads = staticEventQueueThreads; 196 eventQueueThreads = staticEventQueueThreads;
199 eventQueueThreadsLock = staticEventQueueThreadsLock; 197 //eventQueueThreadsLock = staticEventQueueThreadsLock;
200 } 198 }
201 199
202 ReadConfig(); 200 ReadConfig();
@@ -213,7 +211,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
213 EventExecutionMaxQueueSize = m_ScriptEngine.ScriptConfigSource.GetInt("EventExecutionMaxQueueSize", 300); 211 EventExecutionMaxQueueSize = m_ScriptEngine.ScriptConfigSource.GetInt("EventExecutionMaxQueueSize", 300);
214 212
215 // Now refresh config in all threads 213 // Now refresh config in all threads
216 lock (eventQueueThreadsLock) 214 lock (eventQueueThreads)
217 { 215 {
218 foreach (EventQueueThreadClass EventQueueThread in eventQueueThreads) 216 foreach (EventQueueThreadClass EventQueueThread in eventQueueThreads)
219 { 217 {
@@ -232,10 +230,10 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
232 230
233 private void Stop() 231 private void Stop()
234 { 232 {
235 if (eventQueueThreadsLock != null && eventQueueThreads != null) 233 if (eventQueueThreads != null && eventQueueThreads != null)
236 { 234 {
237 // Kill worker threads 235 // Kill worker threads
238 lock (eventQueueThreadsLock) 236 lock (eventQueueThreads)
239 { 237 {
240 foreach (EventQueueThreadClass EventQueueThread in eventQueueThreads) 238 foreach (EventQueueThreadClass EventQueueThread in eventQueueThreads)
241 { 239 {
@@ -247,7 +245,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
247 } 245 }
248 246
249 // Remove all entries from our event queue 247 // Remove all entries from our event queue
250 lock (queueLock) 248 lock (eventQueue)
251 { 249 {
252 eventQueue.Clear(); 250 eventQueue.Clear();
253 } 251 }
@@ -361,7 +359,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
361 /// <param name="param">Array of parameters to match event mask</param> 359 /// <param name="param">Array of parameters to match event mask</param>
362 public void AddToScriptQueue(uint localID, LLUUID itemID, string FunctionName, Queue_llDetectParams_Struct qParams, params object[] param) 360 public void AddToScriptQueue(uint localID, LLUUID itemID, string FunctionName, Queue_llDetectParams_Struct qParams, params object[] param)
363 { 361 {
364 lock (queueLock) 362 lock (eventQueue)
365 { 363 {
366 if (eventQueue.Count >= EventExecutionMaxQueueSize) 364 if (eventQueue.Count >= EventExecutionMaxQueueSize)
367 { 365 {
@@ -396,7 +394,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
396 if (eventQueueThreads.Count == numberOfThreads) 394 if (eventQueueThreads.Count == numberOfThreads)
397 return; 395 return;
398 396
399 lock (eventQueueThreadsLock) 397 lock (eventQueueThreads)
400 { 398 {
401 int diff = numberOfThreads - eventQueueThreads.Count; 399 int diff = numberOfThreads - eventQueueThreads.Count;
402 // Positive number: Start 400 // Positive number: Start
@@ -426,7 +424,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
426 public void CheckScriptMaxExecTime() 424 public void CheckScriptMaxExecTime()
427 { 425 {
428 // Iterate through all ScriptThreadClasses and check how long their current function has been executing 426 // Iterate through all ScriptThreadClasses and check how long their current function has been executing
429 lock (eventQueueThreadsLock) 427 lock (eventQueueThreads)
430 { 428 {
431 foreach (EventQueueThreadClass EventQueueThread in staticGlobalEventQueueThreads) 429 foreach (EventQueueThreadClass EventQueueThread in staticGlobalEventQueueThreads)
432 { 430 {
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueThreadClass.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueThreadClass.cs
index 6f96654..cf66e7a 100644
--- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueThreadClass.cs
+++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueThreadClass.cs
@@ -200,7 +200,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
200 //myScriptEngine.Log.Info("[" + ScriptEngineName + "]: Processing event for localID: " + QIS.localID + ", itemID: " + QIS.itemID + ", FunctionName: " + QIS.FunctionName); 200 //myScriptEngine.Log.Info("[" + ScriptEngineName + "]: Processing event for localID: " + QIS.localID + ", itemID: " + QIS.itemID + ", FunctionName: " + QIS.FunctionName);
201 201
202 // OBJECT BASED LOCK - TWO THREADS WORKING ON SAME OBJECT IS NOT GOOD 202 // OBJECT BASED LOCK - TWO THREADS WORKING ON SAME OBJECT IS NOT GOOD
203 lock (eventQueueManager.queueLock) 203 lock (eventQueueManager.eventQueue)
204 { 204 {
205 GotItem = false; 205 GotItem = false;
206 for (int qc = 0; qc < eventQueueManager.eventQueue.Count; qc++) 206 for (int qc = 0; qc < eventQueueManager.eventQueue.Count; qc++)
@@ -230,12 +230,12 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
230 { 230 {
231///cfk 2-7-08 dont need this right now and the default Linux build has DEBUG defined 231///cfk 2-7-08 dont need this right now and the default Linux build has DEBUG defined
232#if DEBUG 232#if DEBUG
233 eventQueueManager.m_ScriptEngine.Log.Debug("[" + ScriptEngineName + "]: " + 233 //eventQueueManager.m_ScriptEngine.Log.Debug("[" + ScriptEngineName + "]: " +
234 "Executing event:\r\n" 234 // "Executing event:\r\n"
235 + "QIS.localID: " + QIS.localID 235 // + "QIS.localID: " + QIS.localID
236 + ", QIS.itemID: " + QIS.itemID 236 // + ", QIS.itemID: " + QIS.itemID
237 + ", QIS.functionName: " + 237 // + ", QIS.functionName: " +
238 QIS.functionName); 238 // QIS.functionName);
239#endif 239#endif
240 LastExecutionStarted = DateTime.Now.Ticks; 240 LastExecutionStarted = DateTime.Now.Ticks;
241 KillCurrentScript = false; 241 KillCurrentScript = false;