diff --git a/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs b/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs
index 00a99c3ca0..2f5b526c43 100644
--- a/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs
+++ b/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs
@@ -147,7 +147,13 @@ namespace OpenSim.Region.ScriptEngine.Interfaces
///
/// Stop the script instance.
///
+ ///
+ /// This must not be called by a thread that is in the process of handling an event for this script. Otherwise
+ /// there is a danger that it will self-abort and not complete the reset.
+ ///
///
+ /// How many milliseconds we will wait for an existing script event to finish before
+ /// forcibly aborting that event.
/// true if the script was successfully stopped, false otherwise
bool Stop(int timeout);
@@ -169,8 +175,31 @@ namespace OpenSim.Region.ScriptEngine.Interfaces
object EventProcessor();
int EventTime();
- void ResetScript();
+
+ ///
+ /// Reset the script.
+ ///
+ ///
+ /// This must not be called by a thread that is in the process of handling an event for this script. Otherwise
+ /// there is a danger that it will self-abort and not complete the reset. Such a thread must call
+ /// ApiResetScript() instead.
+ ///
+ ///
+ /// How many milliseconds we will wait for an existing script event to finish before
+ /// forcibly aborting that event prior to script reset.
+ ///
+ void ResetScript(int timeout);
+
+ ///
+ /// Reset the script.
+ ///
+ ///
+ /// This must not be called by any thread other than the one executing the scripts current event. This is
+ /// because there is no wait or abort logic if another thread is in the middle of processing a script event.
+ /// Such an external thread should use ResetScript() instead.
+ ///
void ApiResetScript();
+
Dictionary GetVars();
void SetVars(Dictionary vars);
DetectParams GetDetectParams(int idx);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
index dfe8386675..01a5e34ef5 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
@@ -877,7 +877,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
return (DateTime.Now - m_EventStart).Seconds;
}
- public void ResetScript()
+ public void ResetScript(int timeout)
{
if (m_Script == null)
return;
@@ -887,7 +887,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
RemoveState();
ReleaseControls();
- Stop(0);
+ Stop(timeout);
SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID);
part.Inventory.GetInventoryItem(ItemID).PermsMask = 0;
part.Inventory.GetInventoryItem(ItemID).PermsGranter = UUID.Zero;
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index d554656b5a..06f6f12b16 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -1692,7 +1692,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
{
IScriptInstance instance = GetInstance(itemID);
if (instance != null)
- instance.ResetScript();
+ instance.ResetScript(m_WaitForEventCompletionOnScriptStop);
}
public void StartScript(UUID itemID)