Fixed bug that occurs sometimes on script unload where queued script event was attempted executed after AppDomain was unloaded.
parent
0cd6d26adb
commit
25e200c46a
|
@ -131,57 +131,64 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
||||||
QueueItemStruct BlankQIS = new QueueItemStruct();
|
QueueItemStruct BlankQIS = new QueueItemStruct();
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
QueueItemStruct QIS = BlankQIS;
|
try
|
||||||
bool GotItem = false;
|
|
||||||
|
|
||||||
if (EventQueue.Count == 0)
|
|
||||||
{
|
{
|
||||||
// Nothing to do? Sleep a bit waiting for something to do
|
QueueItemStruct QIS = BlankQIS;
|
||||||
Thread.Sleep(NothingToDoSleepms);
|
bool GotItem = false;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Something in queue, process
|
|
||||||
//myScriptEngine.m_logger.Verbose("ScriptEngine", "Processing event for localID: " + QIS.localID + ", itemID: " + QIS.itemID + ", FunctionName: " + QIS.FunctionName);
|
|
||||||
|
|
||||||
// OBJECT BASED LOCK - TWO THREADS WORKING ON SAME OBJECT IS NOT GOOD
|
if (EventQueue.Count == 0)
|
||||||
lock (QueueLock)
|
|
||||||
{
|
{
|
||||||
GotItem = false;
|
// Nothing to do? Sleep a bit waiting for something to do
|
||||||
for (int qc = 0; qc < EventQueue.Count; qc++)
|
Thread.Sleep(NothingToDoSleepms);
|
||||||
{
|
|
||||||
// Get queue item
|
|
||||||
QIS = EventQueue.Dequeue();
|
|
||||||
|
|
||||||
// Check if object is being processed by someone else
|
|
||||||
if (TryLock(QIS.localID) == false)
|
|
||||||
{
|
|
||||||
// Object is already being processed, requeue it
|
|
||||||
EventQueue.Enqueue(QIS);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// We have lock on an object and can process it
|
|
||||||
GotItem = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} // go through queue
|
|
||||||
} // lock
|
|
||||||
|
|
||||||
if (GotItem == true)
|
|
||||||
{
|
|
||||||
// Execute function
|
|
||||||
try
|
|
||||||
{
|
|
||||||
myScriptEngine.myScriptManager.ExecuteEvent(QIS.localID, QIS.itemID, QIS.FunctionName, QIS.param);
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
ReleaseLock(QIS.localID);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Something in queue, process
|
||||||
|
//myScriptEngine.m_logger.Verbose("ScriptEngine", "Processing event for localID: " + QIS.localID + ", itemID: " + QIS.itemID + ", FunctionName: " + QIS.FunctionName);
|
||||||
|
|
||||||
} // Something in queue
|
// OBJECT BASED LOCK - TWO THREADS WORKING ON SAME OBJECT IS NOT GOOD
|
||||||
|
lock (QueueLock)
|
||||||
|
{
|
||||||
|
GotItem = false;
|
||||||
|
for (int qc = 0; qc < EventQueue.Count; qc++)
|
||||||
|
{
|
||||||
|
// Get queue item
|
||||||
|
QIS = EventQueue.Dequeue();
|
||||||
|
|
||||||
|
// Check if object is being processed by someone else
|
||||||
|
if (TryLock(QIS.localID) == false)
|
||||||
|
{
|
||||||
|
// Object is already being processed, requeue it
|
||||||
|
EventQueue.Enqueue(QIS);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// We have lock on an object and can process it
|
||||||
|
GotItem = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} // go through queue
|
||||||
|
} // lock
|
||||||
|
|
||||||
|
if (GotItem == true)
|
||||||
|
{
|
||||||
|
// Execute function
|
||||||
|
try
|
||||||
|
{
|
||||||
|
myScriptEngine.myScriptManager.ExecuteEvent(QIS.localID, QIS.itemID, QIS.FunctionName, QIS.param);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
ReleaseLock(QIS.localID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // Something in queue
|
||||||
|
} catch {ThreadAbortException tae) {
|
||||||
|
throw tae;
|
||||||
|
} catch (Exception e) {
|
||||||
|
Console.WriteLine("Exception in EventQueueThreadLoop: " + e.ToString());
|
||||||
|
}
|
||||||
} // while
|
} // while
|
||||||
} // try
|
} // try
|
||||||
catch (ThreadAbortException tae)
|
catch (ThreadAbortException tae)
|
||||||
|
|
|
@ -362,9 +362,18 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
||||||
// Execute a function in the script
|
// Execute a function in the script
|
||||||
//m_scriptEngine.Log.Verbose("ScriptEngine", "Executing Function localID: " + localID + ", itemID: " + itemID + ", FunctionName: " + FunctionName);
|
//m_scriptEngine.Log.Verbose("ScriptEngine", "Executing Function localID: " + localID + ", itemID: " + itemID + ", FunctionName: " + FunctionName);
|
||||||
LSL_BaseClass Script = m_scriptEngine.myScriptManager.GetScript(localID, itemID);
|
LSL_BaseClass Script = m_scriptEngine.myScriptManager.GetScript(localID, itemID);
|
||||||
|
if (Script == null)
|
||||||
|
return;
|
||||||
|
|
||||||
// Must be done in correct AppDomain, so leaving it up to the script itself
|
// Must be done in correct AppDomain, so leaving it up to the script itself
|
||||||
Script.Exec.ExecuteEvent(FunctionName, args);
|
try
|
||||||
|
{
|
||||||
|
Script.Exec.ExecuteEvent(FunctionName, args);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Exception executing script funcion: " + e.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue