From 824eb7ed20a006a7abf0b1cd4d7f46d9c154647e Mon Sep 17 00:00:00 2001
From: Diva Canto
Date: Sat, 10 Mar 2012 19:51:28 -0800
Subject: Added osGetGridGatekeeperURI()
---
.../ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 14 ++++++++++++++
.../Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 1 +
.../Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 5 +++++
3 files changed, 20 insertions(+)
(limited to 'OpenSim/Region/ScriptEngine/Shared')
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 8edd146..3dbc31a 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -2093,6 +2093,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return HomeURI;
}
+ public string osGetGridGatekeeperURI()
+ {
+ CheckThreatLevel(ThreatLevel.Moderate, "osGetGridGatekeeperURI");
+ m_host.AddScriptLPS(1);
+
+ string gatekeeperURI = String.Empty;
+ IConfigSource config = m_ScriptEngine.ConfigSource;
+
+ if (config.Configs["GridService"] != null)
+ gatekeeperURI = config.Configs["GridService"].GetString("Gatekeeper", gatekeeperURI);
+
+ return gatekeeperURI;
+ }
+
public string osGetGridCustom(string key)
{
CheckThreatLevel(ThreatLevel.Moderate, "osGetGridCustom");
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
index 82a6caf..a5b906f 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
@@ -161,6 +161,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
string osGetGridName();
string osGetGridLoginURI();
string osGetGridHomeURI();
+ string osGetGridGatekeeperURI();
string osGetGridCustom(string key);
LSL_String osFormatString(string str, LSL_List strings);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
index 4341246..e048da2 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
@@ -457,6 +457,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
return m_OSSL_Functions.osGetGridHomeURI();
}
+ public string osGetGridGatekeeperURI()
+ {
+ return m_OSSL_Functions.osGetGridGatekeeperURI();
+ }
+
public string osGetGridCustom(string key)
{
return m_OSSL_Functions.osGetGridCustom(key);
--
cgit v1.1
From 25592bbd852e9350bca25f240d6d54c7a54e28a0 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Mon, 12 Mar 2012 21:16:05 +0000
Subject: Add max thread and min thread information to "xengine status" region
console command
---
OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | 3 +++
1 file changed, 3 insertions(+)
(limited to 'OpenSim/Region/ScriptEngine/Shared')
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
index bc1902b..4010167 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
@@ -578,7 +578,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
return true;
if (!m_InSelfDelete)
+ {
+// m_log.ErrorFormat("[SCRIPT INSTANCE]: Aborting script {0} {1}", ScriptName, ItemID);
result.Abort();
+ }
lock (m_EventQueue)
{
--
cgit v1.1
From 95ec96bf86ebebbc6c2f2c3f3a2bd8ce3f9990f4 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Wed, 14 Mar 2012 00:29:36 +0000
Subject: refactor: rename ScriptInstance.m_CurrentResult to m_CurrentWorkItem
to make it more understandable as to what it is and what it does (hold a
thread pool work item for a waiting of in-progress event)
Also add other various illustrative comments
---
.../ScriptEngine/Shared/Instance/ScriptInstance.cs | 66 ++++++++++++++--------
1 file changed, 44 insertions(+), 22 deletions(-)
(limited to 'OpenSim/Region/ScriptEngine/Shared')
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
index 4010167..b840730 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
@@ -58,7 +58,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private IScriptEngine m_Engine;
- private IScriptWorkItem m_CurrentResult = null;
+
+ ///
+ /// The current work item if an event for this script is running or waiting to run,
+ ///
+ ///
+ /// Null if there is no running or waiting to run event. Must be changed only under an m_EventQueue lock.
+ ///
+ private IScriptWorkItem m_CurrentWorkItem;
+
private Queue m_EventQueue = new Queue(32);
private bool m_RunEvents = false;
private UUID m_ItemID;
@@ -157,7 +165,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
{
// Need to place ourselves back in a work item if there are events to process
if ((m_EventQueue.Count > 0) && m_RunEvents && (!m_ShuttingDown))
- m_CurrentResult = m_Engine.QueueEventHandler(this);
+ m_CurrentWorkItem = m_Engine.QueueEventHandler(this);
}
}
}
@@ -527,8 +535,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
if (m_EventQueue.Count > 0)
{
- if (m_CurrentResult == null)
- m_CurrentResult = m_Engine.QueueEventHandler(this);
+ if (m_CurrentWorkItem == null)
+ m_CurrentWorkItem = m_Engine.QueueEventHandler(this);
// else
// m_log.Error("[Script] Tried to start a script that was already queued");
}
@@ -540,52 +548,58 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
// m_log.DebugFormat(
// "[SCRIPT INSTANCE]: Stopping script {0} {1} with timeout {2}", ScriptName, ItemID, timeout);
- IScriptWorkItem result;
+ IScriptWorkItem workItem;
lock (m_EventQueue)
{
if (!Running)
return true;
- if (m_CurrentResult == null)
+ // If we're not running or waiting to run an event then we can safely stop.
+ if (m_CurrentWorkItem == null)
{
m_RunEvents = false;
return true;
}
- if (m_CurrentResult.Cancel())
+ // If we are waiting to run an event then we can try to cancel it.
+ if (m_CurrentWorkItem.Cancel())
{
- m_CurrentResult = null;
+ m_CurrentWorkItem = null;
m_RunEvents = false;
return true;
}
- result = m_CurrentResult;
+ workItem = m_CurrentWorkItem;
m_RunEvents = false;
}
- if (result.Wait(new TimeSpan((long)timeout * 100000)))
+ // Wait for the current event to complete.
+ if (workItem.Wait(new TimeSpan((long)timeout * 100000)))
{
return true;
}
lock (m_EventQueue)
{
- result = m_CurrentResult;
+ workItem = m_CurrentWorkItem;
}
- if (result == null)
+ if (workItem == null)
return true;
+ // If the event still hasn't stopped and we the stop isn't the result of script or object removal, then
+ // forcibly abort the work item (this aborts the underlying thread).
if (!m_InSelfDelete)
{
// m_log.ErrorFormat("[SCRIPT INSTANCE]: Aborting script {0} {1}", ScriptName, ItemID);
- result.Abort();
+
+ workItem.Abort();
}
lock (m_EventQueue)
{
- m_CurrentResult = null;
+ m_CurrentWorkItem = null;
}
return true;
@@ -606,6 +620,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
throw new EventAbortException();
}
+ ///
+ /// Post an event to this script instance.
+ ///
+ ///
+ /// The request to run the event is sent
+ ///
+ ///
public void PostEvent(EventParams data)
{
// m_log.DebugFormat("[Script] Posted event {2} in state {3} to {0}.{1}",
@@ -672,9 +693,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
m_EventQueue.Enqueue(data);
- if (m_CurrentResult == null)
+ if (m_CurrentWorkItem == null)
{
- m_CurrentResult = m_Engine.QueueEventHandler(this);
+ m_CurrentWorkItem = m_Engine.QueueEventHandler(this);
}
}
}
@@ -701,11 +722,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
{
if ((m_EventQueue.Count > 0) && m_RunEvents && (!m_ShuttingDown))
{
- m_CurrentResult = m_Engine.QueueEventHandler(this);
+ m_CurrentWorkItem = m_Engine.QueueEventHandler(this);
}
else
{
- m_CurrentResult = null;
+ m_CurrentWorkItem = null;
}
return 0;
}
@@ -825,15 +846,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
}
}
+
+ // If there are more events and we are currently running and not shutting down, then ask the
+ // script engine to run the next event.
lock (m_EventQueue)
{
if ((m_EventQueue.Count > 0) && m_RunEvents && (!m_ShuttingDown))
{
- m_CurrentResult = m_Engine.QueueEventHandler(this);
+ m_CurrentWorkItem = m_Engine.QueueEventHandler(this);
}
else
{
- m_CurrentResult = null;
+ m_CurrentWorkItem = null;
}
}
@@ -943,8 +967,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
public void SaveState(string assembly)
{
-
-
// If we're currently in an event, just tell it to save upon return
//
if (m_InEvent)
--
cgit v1.1