One more: Async LSL command thread is also shared now.
parent
9b675a6888
commit
f06a6573bb
|
@ -41,28 +41,36 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class AsyncLSLCommandManager : iScriptEngineFunctionModule
|
public class AsyncLSLCommandManager : iScriptEngineFunctionModule
|
||||||
{
|
{
|
||||||
private Thread cmdHandlerThread;
|
private static Thread cmdHandlerThread;
|
||||||
private int cmdHandlerThreadCycleSleepms;
|
private int cmdHandlerThreadCycleSleepms;
|
||||||
|
|
||||||
private ScriptEngine m_ScriptEngine;
|
private ScriptEngine m_ScriptEngine;
|
||||||
|
|
||||||
public AsyncLSLCommandManager(ScriptEngine _ScriptEngine)
|
public AsyncLSLCommandManager()
|
||||||
{
|
{
|
||||||
m_ScriptEngine = _ScriptEngine;
|
//m_ScriptEngine = _ScriptEngine;
|
||||||
ReadConfig();
|
ReadConfig();
|
||||||
|
|
||||||
// Start the thread that will be doing the work
|
StartThread();
|
||||||
cmdHandlerThread = new Thread(CmdHandlerThreadLoop);
|
}
|
||||||
cmdHandlerThread.Name = "CmdHandlerThread";
|
|
||||||
cmdHandlerThread.Priority = ThreadPriority.BelowNormal;
|
private void StartThread()
|
||||||
cmdHandlerThread.IsBackground = true;
|
{
|
||||||
cmdHandlerThread.Start();
|
if (cmdHandlerThread == null)
|
||||||
OpenSim.Framework.ThreadTracker.Add(cmdHandlerThread);
|
{
|
||||||
|
// Start the thread that will be doing the work
|
||||||
|
cmdHandlerThread = new Thread(CmdHandlerThreadLoop);
|
||||||
|
cmdHandlerThread.Name = "AsyncLSLCmdHandlerThread";
|
||||||
|
cmdHandlerThread.Priority = ThreadPriority.BelowNormal;
|
||||||
|
cmdHandlerThread.IsBackground = true;
|
||||||
|
cmdHandlerThread.Start();
|
||||||
|
OpenSim.Framework.ThreadTracker.Add(cmdHandlerThread);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ReadConfig()
|
public void ReadConfig()
|
||||||
{
|
{
|
||||||
cmdHandlerThreadCycleSleepms = m_ScriptEngine.ScriptConfigSource.GetInt("AsyncLLCommandLoopms", 50);
|
cmdHandlerThreadCycleSleepms = m_ScriptEngine.ScriptConfigSource.GetInt("AsyncLLCommandLoopms", 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
~AsyncLSLCommandManager()
|
~AsyncLSLCommandManager()
|
||||||
|
@ -88,29 +96,46 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
|
||||||
{
|
{
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
// Check timers
|
try
|
||||||
CheckTimerEvents();
|
{
|
||||||
Thread.Sleep(25);
|
while (true)
|
||||||
// Check HttpRequests
|
{
|
||||||
CheckHttpRequests();
|
Thread.Sleep(cmdHandlerThreadCycleSleepms);
|
||||||
Thread.Sleep(25);
|
lock (ScriptEngine.ScriptEngines)
|
||||||
// Check XMLRPCRequests
|
{
|
||||||
CheckXMLRPCRequests();
|
foreach (ScriptEngine se in ScriptEngine.ScriptEngines)
|
||||||
Thread.Sleep(25);
|
{
|
||||||
// Check Listeners
|
m_ScriptEngine = se;
|
||||||
CheckListeners();
|
m_ScriptEngine.m_ASYNCLSLCommandManager.DoOneCmdHandlerPass();
|
||||||
Thread.Sleep(25);
|
}
|
||||||
|
}
|
||||||
// Sleep before next cycle
|
// Sleep before next cycle
|
||||||
//Thread.Sleep(cmdHandlerThreadCycleSleepms);
|
//Thread.Sleep(cmdHandlerThreadCycleSleepms);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal void DoOneCmdHandlerPass()
|
||||||
|
{
|
||||||
|
// Check timers
|
||||||
|
CheckTimerEvents();
|
||||||
|
// Check HttpRequests
|
||||||
|
CheckHttpRequests();
|
||||||
|
// Check XMLRPCRequests
|
||||||
|
CheckXMLRPCRequests();
|
||||||
|
// Check Listeners
|
||||||
|
CheckListeners();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Remove a specific script (and all its pending commands)
|
/// Remove a specific script (and all its pending commands)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="m_localID"></param>
|
/// <param name="localID"></param>
|
||||||
/// <param name="m_itemID"></param>
|
/// <param name="itemID"></param>
|
||||||
public void RemoveScript(uint localID, LLUUID itemID)
|
public void RemoveScript(uint localID, LLUUID itemID)
|
||||||
{
|
{
|
||||||
// Remove a specific script
|
// Remove a specific script
|
||||||
|
|
|
@ -73,38 +73,40 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
|
||||||
|
|
||||||
public void ReadConfig()
|
public void ReadConfig()
|
||||||
{
|
{
|
||||||
foreach (ScriptEngine m_ScriptEngine in new ArrayList(ScriptEngine.ScriptEngines))
|
//lock (ScriptEngine.ScriptEngines)
|
||||||
{
|
//{
|
||||||
ScriptEngineName = m_ScriptEngine.ScriptEngineName;
|
foreach (ScriptEngine m_ScriptEngine in new ArrayList(ScriptEngine.ScriptEngines))
|
||||||
nothingToDoSleepms = m_ScriptEngine.ScriptConfigSource.GetInt("SleepTimeIfNoScriptExecutionMs", 50);
|
|
||||||
|
|
||||||
// Later with ScriptServer we might want to ask OS for stuff too, so doing this a bit manually
|
|
||||||
string pri = m_ScriptEngine.ScriptConfigSource.GetString("ScriptThreadPriority", "BelowNormal");
|
|
||||||
switch (pri.ToLower())
|
|
||||||
{
|
{
|
||||||
case "lowest":
|
ScriptEngineName = m_ScriptEngine.ScriptEngineName;
|
||||||
MyThreadPriority = ThreadPriority.Lowest;
|
nothingToDoSleepms = m_ScriptEngine.ScriptConfigSource.GetInt("SleepTimeIfNoScriptExecutionMs", 50);
|
||||||
break;
|
|
||||||
case "belownormal":
|
|
||||||
MyThreadPriority = ThreadPriority.BelowNormal;
|
|
||||||
break;
|
|
||||||
case "normal":
|
|
||||||
MyThreadPriority = ThreadPriority.Normal;
|
|
||||||
break;
|
|
||||||
case "abovenormal":
|
|
||||||
MyThreadPriority = ThreadPriority.AboveNormal;
|
|
||||||
break;
|
|
||||||
case "highest":
|
|
||||||
MyThreadPriority = ThreadPriority.Highest;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
MyThreadPriority = ThreadPriority.BelowNormal; // Default
|
|
||||||
m_ScriptEngine.Log.Error("[ScriptEngineBase]: Unknown priority type \"" + pri +
|
|
||||||
"\" in config file. Defaulting to \"BelowNormal\".");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Later with ScriptServer we might want to ask OS for stuff too, so doing this a bit manually
|
||||||
|
string pri = m_ScriptEngine.ScriptConfigSource.GetString("ScriptThreadPriority", "BelowNormal");
|
||||||
|
switch (pri.ToLower())
|
||||||
|
{
|
||||||
|
case "lowest":
|
||||||
|
MyThreadPriority = ThreadPriority.Lowest;
|
||||||
|
break;
|
||||||
|
case "belownormal":
|
||||||
|
MyThreadPriority = ThreadPriority.BelowNormal;
|
||||||
|
break;
|
||||||
|
case "normal":
|
||||||
|
MyThreadPriority = ThreadPriority.Normal;
|
||||||
|
break;
|
||||||
|
case "abovenormal":
|
||||||
|
MyThreadPriority = ThreadPriority.AboveNormal;
|
||||||
|
break;
|
||||||
|
case "highest":
|
||||||
|
MyThreadPriority = ThreadPriority.Highest;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
MyThreadPriority = ThreadPriority.BelowNormal; // Default
|
||||||
|
m_ScriptEngine.Log.Error("[ScriptEngineBase]: Unknown priority type \"" + pri +
|
||||||
|
"\" in config file. Defaulting to \"BelowNormal\".");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//}
|
||||||
// Now set that priority
|
// Now set that priority
|
||||||
if (EventQueueThread != null)
|
if (EventQueueThread != null)
|
||||||
if (EventQueueThread.IsAlive)
|
if (EventQueueThread.IsAlive)
|
||||||
|
@ -187,159 +189,163 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
|
||||||
|
|
||||||
public void DoProcessQueue()
|
public void DoProcessQueue()
|
||||||
{
|
{
|
||||||
foreach (ScriptEngine m_ScriptEngine in new ArrayList(ScriptEngine.ScriptEngines))
|
//lock (ScriptEngine.ScriptEngines)
|
||||||
{
|
//{
|
||||||
lastScriptEngine = m_ScriptEngine;
|
foreach (ScriptEngine m_ScriptEngine in new ArrayList(ScriptEngine.ScriptEngines))
|
||||||
// Every now and then check if we should shut down
|
|
||||||
//if (PleaseShutdown || EventQueueManager.ThreadsToExit > 0)
|
|
||||||
//{
|
|
||||||
// // Someone should shut down, lets get exclusive lock
|
|
||||||
// lock (EventQueueManager.ThreadsToExitLock)
|
|
||||||
// {
|
|
||||||
// // Lets re-check in case someone grabbed it
|
|
||||||
// if (EventQueueManager.ThreadsToExit > 0)
|
|
||||||
// {
|
|
||||||
// // Its crowded here so we'll shut down
|
|
||||||
// EventQueueManager.ThreadsToExit--;
|
|
||||||
// Stop();
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// // We have been asked to shut down
|
|
||||||
// Stop();
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
//try
|
|
||||||
// {
|
|
||||||
EventQueueManager.QueueItemStruct QIS = BlankQIS;
|
|
||||||
bool GotItem = false;
|
|
||||||
|
|
||||||
//if (PleaseShutdown)
|
|
||||||
// return;
|
|
||||||
|
|
||||||
if (m_ScriptEngine.m_EventQueueManager.eventQueue.Count == 0)
|
|
||||||
{
|
{
|
||||||
// Nothing to do? Sleep a bit waiting for something to do
|
lastScriptEngine = m_ScriptEngine;
|
||||||
Thread.Sleep(nothingToDoSleepms);
|
// Every now and then check if we should shut down
|
||||||
}
|
//if (PleaseShutdown || EventQueueManager.ThreadsToExit > 0)
|
||||||
else
|
//{
|
||||||
{
|
// // Someone should shut down, lets get exclusive lock
|
||||||
// Something in queue, process
|
// lock (EventQueueManager.ThreadsToExitLock)
|
||||||
//myScriptEngine.Log.Info("[" + ScriptEngineName + "]: Processing event for localID: " + QIS.localID + ", itemID: " + QIS.itemID + ", FunctionName: " + QIS.FunctionName);
|
// {
|
||||||
|
// // Lets re-check in case someone grabbed it
|
||||||
|
// if (EventQueueManager.ThreadsToExit > 0)
|
||||||
|
// {
|
||||||
|
// // Its crowded here so we'll shut down
|
||||||
|
// EventQueueManager.ThreadsToExit--;
|
||||||
|
// Stop();
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// // We have been asked to shut down
|
||||||
|
// Stop();
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
// OBJECT BASED LOCK - TWO THREADS WORKING ON SAME OBJECT IS NOT GOOD
|
//try
|
||||||
lock (m_ScriptEngine.m_EventQueueManager.eventQueue)
|
// {
|
||||||
|
EventQueueManager.QueueItemStruct QIS = BlankQIS;
|
||||||
|
bool GotItem = false;
|
||||||
|
|
||||||
|
//if (PleaseShutdown)
|
||||||
|
// return;
|
||||||
|
|
||||||
|
if (m_ScriptEngine.m_EventQueueManager.eventQueue.Count == 0)
|
||||||
{
|
{
|
||||||
GotItem = false;
|
// Nothing to do? Sleep a bit waiting for something to do
|
||||||
for (int qc = 0; qc < m_ScriptEngine.m_EventQueueManager.eventQueue.Count; qc++)
|
Thread.Sleep(nothingToDoSleepms);
|
||||||
{
|
|
||||||
// Get queue item
|
|
||||||
QIS = m_ScriptEngine.m_EventQueueManager.eventQueue.Dequeue();
|
|
||||||
|
|
||||||
// Check if object is being processed by someone else
|
|
||||||
if (m_ScriptEngine.m_EventQueueManager.TryLock(QIS.localID) == false)
|
|
||||||
{
|
|
||||||
// Object is already being processed, requeue it
|
|
||||||
m_ScriptEngine.m_EventQueueManager.eventQueue.Enqueue(QIS);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// We have lock on an object and can process it
|
|
||||||
GotItem = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if (GotItem == true)
|
|
||||||
{
|
{
|
||||||
// Execute function
|
// Something in queue, process
|
||||||
try
|
//myScriptEngine.Log.Info("[" + ScriptEngineName + "]: Processing event for localID: " + QIS.localID + ", itemID: " + QIS.itemID + ", FunctionName: " + QIS.FunctionName);
|
||||||
{
|
|
||||||
///cfk 2-7-08 dont need this right now and the default Linux build has DEBUG defined
|
|
||||||
#if DEBUG
|
|
||||||
//eventQueueManager.m_ScriptEngine.Log.Debug("[" + ScriptEngineName + "]: " +
|
|
||||||
// "Executing event:\r\n"
|
|
||||||
// + "QIS.localID: " + QIS.localID
|
|
||||||
// + ", QIS.itemID: " + QIS.itemID
|
|
||||||
// + ", QIS.functionName: " +
|
|
||||||
// QIS.functionName);
|
|
||||||
#endif
|
|
||||||
LastExecutionStarted = DateTime.Now.Ticks;
|
|
||||||
KillCurrentScript = false;
|
|
||||||
InExecution = true;
|
|
||||||
m_ScriptEngine.m_ScriptManager.ExecuteEvent(QIS.localID,
|
|
||||||
QIS.itemID,
|
|
||||||
QIS.functionName,
|
|
||||||
QIS.llDetectParams,
|
|
||||||
QIS.param);
|
|
||||||
InExecution = false;
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
InExecution = false;
|
|
||||||
// DISPLAY ERROR INWORLD
|
|
||||||
string text = "Error executing script function \"" + QIS.functionName +
|
|
||||||
"\":\r\n";
|
|
||||||
if (e.InnerException != null)
|
|
||||||
{
|
|
||||||
// Send inner exception
|
|
||||||
text += e.InnerException.Message.ToString();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
text += "\r\n";
|
|
||||||
// Send normal
|
|
||||||
text += e.Message.ToString();
|
|
||||||
}
|
|
||||||
if (KillCurrentScript)
|
|
||||||
text += "\r\nScript will be deactivated!";
|
|
||||||
|
|
||||||
try
|
// OBJECT BASED LOCK - TWO THREADS WORKING ON SAME OBJECT IS NOT GOOD
|
||||||
|
lock (m_ScriptEngine.m_EventQueueManager.eventQueue)
|
||||||
|
{
|
||||||
|
GotItem = false;
|
||||||
|
for (int qc = 0; qc < m_ScriptEngine.m_EventQueueManager.eventQueue.Count; qc++)
|
||||||
{
|
{
|
||||||
if (text.Length > 1500)
|
// Get queue item
|
||||||
text = text.Substring(0, 1500);
|
QIS = m_ScriptEngine.m_EventQueueManager.eventQueue.Dequeue();
|
||||||
IScriptHost m_host =
|
|
||||||
m_ScriptEngine.World.GetSceneObjectPart(QIS.localID);
|
// Check if object is being processed by someone else
|
||||||
//if (m_host != null)
|
if (m_ScriptEngine.m_EventQueueManager.TryLock(QIS.localID) == false)
|
||||||
//{
|
|
||||||
m_ScriptEngine.World.SimChat(Helpers.StringToField(text),
|
|
||||||
ChatTypeEnum.Say, 0,
|
|
||||||
m_host.AbsolutePosition,
|
|
||||||
m_host.Name, m_host.UUID);
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
//}
|
|
||||||
//else
|
|
||||||
//{
|
|
||||||
// T oconsole
|
|
||||||
m_ScriptEngine.m_EventQueueManager.m_ScriptEngine.Log.Error("[" + ScriptEngineName + "]: " +
|
|
||||||
"Unable to send text in-world:\r\n" +
|
|
||||||
text);
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
// So we are done sending message in-world
|
|
||||||
if (KillCurrentScript)
|
|
||||||
{
|
{
|
||||||
m_ScriptEngine.m_EventQueueManager.m_ScriptEngine.m_ScriptManager.StopScript(
|
// Object is already being processed, requeue it
|
||||||
QIS.localID, QIS.itemID);
|
m_ScriptEngine.m_EventQueueManager.eventQueue.Enqueue(QIS);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// We have lock on an object and can process it
|
||||||
|
GotItem = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
|
if (GotItem == true)
|
||||||
{
|
{
|
||||||
InExecution = false;
|
// Execute function
|
||||||
m_ScriptEngine.m_EventQueueManager.ReleaseLock(QIS.localID);
|
try
|
||||||
|
{
|
||||||
|
///cfk 2-7-08 dont need this right now and the default Linux build has DEBUG defined
|
||||||
|
#if DEBUG
|
||||||
|
//eventQueueManager.m_ScriptEngine.Log.Debug("[" + ScriptEngineName + "]: " +
|
||||||
|
// "Executing event:\r\n"
|
||||||
|
// + "QIS.localID: " + QIS.localID
|
||||||
|
// + ", QIS.itemID: " + QIS.itemID
|
||||||
|
// + ", QIS.functionName: " +
|
||||||
|
// QIS.functionName);
|
||||||
|
#endif
|
||||||
|
LastExecutionStarted = DateTime.Now.Ticks;
|
||||||
|
KillCurrentScript = false;
|
||||||
|
InExecution = true;
|
||||||
|
m_ScriptEngine.m_ScriptManager.ExecuteEvent(QIS.localID,
|
||||||
|
QIS.itemID,
|
||||||
|
QIS.functionName,
|
||||||
|
QIS.llDetectParams,
|
||||||
|
QIS.param);
|
||||||
|
InExecution = false;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
InExecution = false;
|
||||||
|
// DISPLAY ERROR INWORLD
|
||||||
|
string text = "Error executing script function \"" + QIS.functionName +
|
||||||
|
"\":\r\n";
|
||||||
|
if (e.InnerException != null)
|
||||||
|
{
|
||||||
|
// Send inner exception
|
||||||
|
text += e.InnerException.Message.ToString();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
text += "\r\n";
|
||||||
|
// Send normal
|
||||||
|
text += e.Message.ToString();
|
||||||
|
}
|
||||||
|
if (KillCurrentScript)
|
||||||
|
text += "\r\nScript will be deactivated!";
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (text.Length > 1500)
|
||||||
|
text = text.Substring(0, 1500);
|
||||||
|
IScriptHost m_host =
|
||||||
|
m_ScriptEngine.World.GetSceneObjectPart(QIS.localID);
|
||||||
|
//if (m_host != null)
|
||||||
|
//{
|
||||||
|
m_ScriptEngine.World.SimChat(Helpers.StringToField(text),
|
||||||
|
ChatTypeEnum.Say, 0,
|
||||||
|
m_host.AbsolutePosition,
|
||||||
|
m_host.Name, m_host.UUID);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
//}
|
||||||
|
//else
|
||||||
|
//{
|
||||||
|
// T oconsole
|
||||||
|
m_ScriptEngine.m_EventQueueManager.m_ScriptEngine.Log.Error("[" + ScriptEngineName +
|
||||||
|
"]: " +
|
||||||
|
"Unable to send text in-world:\r\n" +
|
||||||
|
text);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
// So we are done sending message in-world
|
||||||
|
if (KillCurrentScript)
|
||||||
|
{
|
||||||
|
m_ScriptEngine.m_EventQueueManager.m_ScriptEngine.m_ScriptManager.StopScript(
|
||||||
|
QIS.localID, QIS.itemID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
InExecution = false;
|
||||||
|
m_ScriptEngine.m_EventQueueManager.ReleaseLock(QIS.localID);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
///// <summary>
|
///// <summary>
|
||||||
|
|
|
@ -63,13 +63,18 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
|
||||||
public void ReadConfig()
|
public void ReadConfig()
|
||||||
{
|
{
|
||||||
// Bad hack, but we need a m_ScriptEngine :)
|
// Bad hack, but we need a m_ScriptEngine :)
|
||||||
foreach (ScriptEngine m_ScriptEngine in ScriptEngine.ScriptEngines)
|
lock (ScriptEngine.ScriptEngines)
|
||||||
{
|
{
|
||||||
MaintenanceLoopms = m_ScriptEngine.ScriptConfigSource.GetInt("MaintenanceLoopms", 50);
|
foreach (ScriptEngine m_ScriptEngine in ScriptEngine.ScriptEngines)
|
||||||
MaintenanceLoopTicks_ScriptLoadUnload = m_ScriptEngine.ScriptConfigSource.GetInt("MaintenanceLoopTicks_ScriptLoadUnload", 1);
|
{
|
||||||
MaintenanceLoopTicks_Other = m_ScriptEngine.ScriptConfigSource.GetInt("MaintenanceLoopTicks_Other", 10);
|
MaintenanceLoopms = m_ScriptEngine.ScriptConfigSource.GetInt("MaintenanceLoopms", 50);
|
||||||
|
MaintenanceLoopTicks_ScriptLoadUnload =
|
||||||
|
m_ScriptEngine.ScriptConfigSource.GetInt("MaintenanceLoopTicks_ScriptLoadUnload", 1);
|
||||||
|
MaintenanceLoopTicks_Other =
|
||||||
|
m_ScriptEngine.ScriptConfigSource.GetInt("MaintenanceLoopTicks_Other", 10);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,52 +164,53 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
|
||||||
MaintenanceLoopTicks_Other_Count++;
|
MaintenanceLoopTicks_Other_Count++;
|
||||||
|
|
||||||
|
|
||||||
foreach (ScriptEngine m_ScriptEngine in new ArrayList(ScriptEngine.ScriptEngines))
|
lock (ScriptEngine.ScriptEngines)
|
||||||
{
|
{
|
||||||
lastScriptEngine = m_ScriptEngine;
|
foreach (ScriptEngine m_ScriptEngine in ScriptEngine.ScriptEngines)
|
||||||
// Re-reading config every x seconds
|
|
||||||
if (MaintenanceLoopTicks_Other_Count >= MaintenanceLoopTicks_Other)
|
|
||||||
{
|
{
|
||||||
MaintenanceLoopTicks_Other_ResetCount = true;
|
lastScriptEngine = m_ScriptEngine;
|
||||||
if (m_ScriptEngine.RefreshConfigFilens > 0)
|
// Re-reading config every x seconds
|
||||||
|
if (MaintenanceLoopTicks_Other_Count >= MaintenanceLoopTicks_Other)
|
||||||
{
|
{
|
||||||
|
MaintenanceLoopTicks_Other_ResetCount = true;
|
||||||
// Check if its time to re-read config
|
if (m_ScriptEngine.RefreshConfigFilens > 0)
|
||||||
if (DateTime.Now.Ticks - Last_ReReadConfigFilens >
|
|
||||||
m_ScriptEngine.RefreshConfigFilens)
|
|
||||||
{
|
{
|
||||||
//Console.WriteLine("Time passed: " + (DateTime.Now.Ticks - Last_ReReadConfigFilens) + ">" + m_ScriptEngine.RefreshConfigFilens );
|
// Check if its time to re-read config
|
||||||
// Its time to re-read config file
|
if (DateTime.Now.Ticks - Last_ReReadConfigFilens >
|
||||||
m_ScriptEngine.ReadConfig();
|
m_ScriptEngine.RefreshConfigFilens)
|
||||||
Last_ReReadConfigFilens = DateTime.Now.Ticks; // Reset time
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Adjust number of running script threads if not correct
|
|
||||||
if (m_ScriptEngine.m_EventQueueManager != null)
|
|
||||||
m_ScriptEngine.m_EventQueueManager.AdjustNumberOfScriptThreads();
|
|
||||||
|
|
||||||
// Check if any script has exceeded its max execution time
|
|
||||||
if (EventQueueManager.EnforceMaxExecutionTime)
|
|
||||||
{
|
|
||||||
// We are enforcing execution time
|
|
||||||
if (DateTime.Now.Ticks - Last_maxFunctionExecutionTimens >
|
|
||||||
EventQueueManager.maxFunctionExecutionTimens)
|
|
||||||
{
|
{
|
||||||
// Its time to check again
|
//Console.WriteLine("Time passed: " + (DateTime.Now.Ticks - Last_ReReadConfigFilens) + ">" + m_ScriptEngine.RefreshConfigFilens );
|
||||||
m_ScriptEngine.m_EventQueueManager.CheckScriptMaxExecTime(); // Do check
|
// Its time to re-read config file
|
||||||
Last_maxFunctionExecutionTimens = DateTime.Now.Ticks; // Reset time
|
m_ScriptEngine.ReadConfig();
|
||||||
|
Last_ReReadConfigFilens = DateTime.Now.Ticks; // Reset time
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Adjust number of running script threads if not correct
|
||||||
|
if (m_ScriptEngine.m_EventQueueManager != null)
|
||||||
|
m_ScriptEngine.m_EventQueueManager.AdjustNumberOfScriptThreads();
|
||||||
|
|
||||||
|
// Check if any script has exceeded its max execution time
|
||||||
|
if (EventQueueManager.EnforceMaxExecutionTime)
|
||||||
|
{
|
||||||
|
// We are enforcing execution time
|
||||||
|
if (DateTime.Now.Ticks - Last_maxFunctionExecutionTimens >
|
||||||
|
EventQueueManager.maxFunctionExecutionTimens)
|
||||||
|
{
|
||||||
|
// Its time to check again
|
||||||
|
m_ScriptEngine.m_EventQueueManager.CheckScriptMaxExecTime(); // Do check
|
||||||
|
Last_maxFunctionExecutionTimens = DateTime.Now.Ticks; // Reset time
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (MaintenanceLoopTicks_ScriptLoadUnload_Count >= MaintenanceLoopTicks_ScriptLoadUnload)
|
||||||
}
|
{
|
||||||
if (MaintenanceLoopTicks_ScriptLoadUnload_Count >= MaintenanceLoopTicks_ScriptLoadUnload)
|
MaintenanceLoopTicks_ScriptLoadUnload_ResetCount = true;
|
||||||
{
|
// LOAD / UNLOAD SCRIPTS
|
||||||
MaintenanceLoopTicks_ScriptLoadUnload_ResetCount = true;
|
if (m_ScriptEngine.m_ScriptManager != null)
|
||||||
// LOAD / UNLOAD SCRIPTS
|
m_ScriptEngine.m_ScriptManager.DoScriptLoadUnload();
|
||||||
if (m_ScriptEngine.m_ScriptManager != null)
|
}
|
||||||
m_ScriptEngine.m_ScriptManager.DoScriptLoadUnload();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,7 +84,10 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
|
||||||
public ScriptEngine()
|
public ScriptEngine()
|
||||||
{
|
{
|
||||||
Common.mySE = this; // For logging, just need any instance, doesn't matter
|
Common.mySE = this; // For logging, just need any instance, doesn't matter
|
||||||
ScriptEngines.Add(this); // Keep a list of ScriptEngines for shared threads to process all instances
|
lock (ScriptEngines)
|
||||||
|
{
|
||||||
|
ScriptEngines.Add(this); // Keep a list of ScriptEngines for shared threads to process all instances
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void InitializeEngine(Scene Sceneworld, IConfigSource config, bool HookUpToServer, ScriptManager newScriptManager)
|
public void InitializeEngine(Scene Sceneworld, IConfigSource config, bool HookUpToServer, ScriptManager newScriptManager)
|
||||||
|
@ -107,7 +110,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
|
||||||
newScriptManager.Start();
|
newScriptManager.Start();
|
||||||
m_ScriptManager = newScriptManager;
|
m_ScriptManager = newScriptManager;
|
||||||
m_AppDomainManager = new AppDomainManager(this);
|
m_AppDomainManager = new AppDomainManager(this);
|
||||||
m_ASYNCLSLCommandManager = new AsyncLSLCommandManager(this);
|
m_ASYNCLSLCommandManager = new AsyncLSLCommandManager();
|
||||||
if (m_MaintenanceThread == null)
|
if (m_MaintenanceThread == null)
|
||||||
m_MaintenanceThread = new MaintenanceThread();
|
m_MaintenanceThread = new MaintenanceThread();
|
||||||
|
|
||||||
|
@ -121,7 +124,10 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
|
||||||
public void Shutdown()
|
public void Shutdown()
|
||||||
{
|
{
|
||||||
// We are shutting down
|
// We are shutting down
|
||||||
ScriptEngines.Remove(this);
|
lock (ScriptEngines)
|
||||||
|
{
|
||||||
|
ScriptEngines.Remove(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ScriptServerInterfaces.RemoteEvents ScriptServerInterfaces.ScriptEngine.EventManager()
|
ScriptServerInterfaces.RemoteEvents ScriptServerInterfaces.ScriptEngine.EventManager()
|
||||||
|
@ -136,13 +142,6 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
|
||||||
#endif
|
#endif
|
||||||
RefreshConfigFileSeconds = ScriptConfigSource.GetInt("RefreshConfig", 30);
|
RefreshConfigFileSeconds = ScriptConfigSource.GetInt("RefreshConfig", 30);
|
||||||
|
|
||||||
// Reload from disk? No!
|
|
||||||
//ConfigSource.Reload();
|
|
||||||
//if (File.Exists(OpenSim.Application.iniFilePath))
|
|
||||||
//{
|
|
||||||
// //ConfigSource.Merge(new IniConfigSource(OpenSim.Application.iniFilePath));
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
|
||||||
// Create a new object (probably not necessary?)
|
// Create a new object (probably not necessary?)
|
||||||
// ScriptConfigSource = ConfigSource.Configs[ScriptEngineName];
|
// ScriptConfigSource = ConfigSource.Configs[ScriptEngineName];
|
||||||
|
@ -179,15 +178,6 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// If set to true then threads and stuff should try to make a graceful exit
|
|
||||||
/// </summary>
|
|
||||||
//public bool PleaseShutdown
|
|
||||||
//{
|
|
||||||
// get { return _PleaseShutdown; }
|
|
||||||
// set { _PleaseShutdown = value; }
|
|
||||||
//}
|
|
||||||
//private bool _PleaseShutdown = false;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -210,12 +210,6 @@ SleepTimeIfNoScriptExecutionMs=50
|
||||||
; Each AppDomain has some memory overhead. But leaving dead scripts in memory also has memory overhead.
|
; Each AppDomain has some memory overhead. But leaving dead scripts in memory also has memory overhead.
|
||||||
ScriptsPerAppDomain=1
|
ScriptsPerAppDomain=1
|
||||||
|
|
||||||
; Script loading / unloading sleep
|
|
||||||
; How long load/unload thread should sleep if there is nothing to do
|
|
||||||
; Higher value makes it respond slower when scripts are added/removed from prims
|
|
||||||
; But once active it will process all in queue before sleeping again
|
|
||||||
|
|
||||||
|
|
||||||
; MaintenanceLoop
|
; MaintenanceLoop
|
||||||
; How often to run maintenance loop
|
; How often to run maintenance loop
|
||||||
; Maintenance loop is doing: script compile/load, script unload, reload config, adjust running config and enforce max execution time
|
; Maintenance loop is doing: script compile/load, script unload, reload config, adjust running config and enforce max execution time
|
||||||
|
@ -224,6 +218,10 @@ MaintenanceLoopms=50
|
||||||
; How many maintenanceloops between each of these.
|
; How many maintenanceloops between each of these.
|
||||||
; (if 2 then function will be executed every MaintenanceLoopms*2 ms)
|
; (if 2 then function will be executed every MaintenanceLoopms*2 ms)
|
||||||
; Script loading/unloading
|
; Script loading/unloading
|
||||||
|
|
||||||
|
; How long load/unload thread should sleep if there is nothing to do
|
||||||
|
; Higher value makes it respond slower when scripts are added/removed from prims
|
||||||
|
; But once active it will process all in queue before sleeping again
|
||||||
MaintenanceLoopTicks_ScriptLoadUnload=1
|
MaintenanceLoopTicks_ScriptLoadUnload=1
|
||||||
|
|
||||||
; Other tasks
|
; Other tasks
|
||||||
|
|
Loading…
Reference in New Issue