aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine
diff options
context:
space:
mode:
authorTedd Hansen2007-08-26 08:20:48 +0000
committerTedd Hansen2007-08-26 08:20:48 +0000
commit25e200c46a7664eb23499c39e6a1019470e26edc (patch)
tree5b15196e57636dd45f7c530435ba1f665a2c6e20 /OpenSim/Region/ScriptEngine
parentFixed error on shutdown caused by ThreadAbortException sending message throug... (diff)
downloadopensim-SC_OLD-25e200c46a7664eb23499c39e6a1019470e26edc.zip
opensim-SC_OLD-25e200c46a7664eb23499c39e6a1019470e26edc.tar.gz
opensim-SC_OLD-25e200c46a7664eb23499c39e6a1019470e26edc.tar.bz2
opensim-SC_OLD-25e200c46a7664eb23499c39e6a1019470e26edc.tar.xz
Fixed bug that occurs sometimes on script unload where queued script event was attempted executed after AppDomain was unloaded.
Diffstat (limited to 'OpenSim/Region/ScriptEngine')
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueManager.cs87
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs11
2 files changed, 57 insertions, 41 deletions
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueManager.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueManager.cs
index 99971a5..9037c2a 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueManager.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueManager.cs
@@ -131,57 +131,64 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
131 QueueItemStruct BlankQIS = new QueueItemStruct(); 131 QueueItemStruct BlankQIS = new QueueItemStruct();
132 while (true) 132 while (true)
133 { 133 {
134 QueueItemStruct QIS = BlankQIS; 134 try
135 bool GotItem = false;
136
137 if (EventQueue.Count == 0)
138 {
139 // Nothing to do? Sleep a bit waiting for something to do
140 Thread.Sleep(NothingToDoSleepms);
141 }
142 else
143 { 135 {
144 // Something in queue, process 136 QueueItemStruct QIS = BlankQIS;
145 //myScriptEngine.m_logger.Verbose("ScriptEngine", "Processing event for localID: " + QIS.localID + ", itemID: " + QIS.itemID + ", FunctionName: " + QIS.FunctionName); 137 bool GotItem = false;
146 138
147 // OBJECT BASED LOCK - TWO THREADS WORKING ON SAME OBJECT IS NOT GOOD 139 if (EventQueue.Count == 0)
148 lock (QueueLock)
149 { 140 {
150 GotItem = false; 141 // Nothing to do? Sleep a bit waiting for something to do
151 for (int qc = 0; qc < EventQueue.Count; qc++) 142 Thread.Sleep(NothingToDoSleepms);
143 }
144 else
145 {
146 // Something in queue, process
147 //myScriptEngine.m_logger.Verbose("ScriptEngine", "Processing event for localID: " + QIS.localID + ", itemID: " + QIS.itemID + ", FunctionName: " + QIS.FunctionName);
148
149 // OBJECT BASED LOCK - TWO THREADS WORKING ON SAME OBJECT IS NOT GOOD
150 lock (QueueLock)
152 { 151 {
153 // Get queue item 152 GotItem = false;
154 QIS = EventQueue.Dequeue(); 153 for (int qc = 0; qc < EventQueue.Count; qc++)
154 {
155 // Get queue item
156 QIS = EventQueue.Dequeue();
157
158 // Check if object is being processed by someone else
159 if (TryLock(QIS.localID) == false)
160 {
161 // Object is already being processed, requeue it
162 EventQueue.Enqueue(QIS);
163 }
164 else
165 {
166 // We have lock on an object and can process it
167 GotItem = true;
168 break;
169 }
170 } // go through queue
171 } // lock
155 172
156 // Check if object is being processed by someone else 173 if (GotItem == true)
157 if (TryLock(QIS.localID) == false) 174 {
175 // Execute function
176 try
158 { 177 {
159 // Object is already being processed, requeue it 178 myScriptEngine.myScriptManager.ExecuteEvent(QIS.localID, QIS.itemID, QIS.FunctionName, QIS.param);
160 EventQueue.Enqueue(QIS);
161 } 179 }
162 else 180 finally
163 { 181 {
164 // We have lock on an object and can process it 182 ReleaseLock(QIS.localID);
165 GotItem = true;
166 break;
167 } 183 }
168 } // go through queue
169 } // lock
170
171 if (GotItem == true)
172 {
173 // Execute function
174 try
175 {
176 myScriptEngine.myScriptManager.ExecuteEvent(QIS.localID, QIS.itemID, QIS.FunctionName, QIS.param);
177 } 184 }
178 finally
179 {
180 ReleaseLock(QIS.localID);
181 }
182 }
183 185
184 } // Something in queue 186 } // Something in queue
187 } catch {ThreadAbortException tae) {
188 throw tae;
189 } catch (Exception e) {
190 Console.WriteLine("Exception in EventQueueThreadLoop: " + e.ToString());
191 }
185 } // while 192 } // while
186 } // try 193 } // try
187 catch (ThreadAbortException tae) 194 catch (ThreadAbortException tae)
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs
index c7c33bb..5dc928a 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs
@@ -362,9 +362,18 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
362 // Execute a function in the script 362 // Execute a function in the script
363 //m_scriptEngine.Log.Verbose("ScriptEngine", "Executing Function localID: " + localID + ", itemID: " + itemID + ", FunctionName: " + FunctionName); 363 //m_scriptEngine.Log.Verbose("ScriptEngine", "Executing Function localID: " + localID + ", itemID: " + itemID + ", FunctionName: " + FunctionName);
364 LSL_BaseClass Script = m_scriptEngine.myScriptManager.GetScript(localID, itemID); 364 LSL_BaseClass Script = m_scriptEngine.myScriptManager.GetScript(localID, itemID);
365 if (Script == null)
366 return;
365 367
366 // Must be done in correct AppDomain, so leaving it up to the script itself 368 // Must be done in correct AppDomain, so leaving it up to the script itself
367 Script.Exec.ExecuteEvent(FunctionName, args); 369 try
370 {
371 Script.Exec.ExecuteEvent(FunctionName, args);
372 }
373 catch (Exception e)
374 {
375 Console.WriteLine("Exception executing script funcion: " + e.ToString());
376 }
368 377
369 } 378 }
370 379