Extend default 1 second wait for event completion to other thread script reset (as called by llResetOtherScript()).

As with script stop (via llDie()) aborting other scripts event threads, llResetOtherScript() can also abort any current event thread on another script.
On mono 2.6, 2.10 and possibly later this may cause locking problems in certain code areas.
This commit reuses the recently introduced [XEngine] WaitForEventCompletionOnScriptStop to make this a 1 sec timeout, rather than 0 secs.
0.7.5-pf-bulletsim
Justin Clark-Casey (justincc) 2012-12-17 21:37:02 +00:00
parent 021623a17d
commit e6fd8365af
3 changed files with 33 additions and 4 deletions

View File

@ -147,7 +147,13 @@ namespace OpenSim.Region.ScriptEngine.Interfaces
/// <summary> /// <summary>
/// Stop the script instance. /// Stop the script instance.
/// </summary> /// </summary>
/// <remarks>
/// 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.
/// </remarks>
/// <param name="timeout"></param> /// <param name="timeout"></param>
/// How many milliseconds we will wait for an existing script event to finish before
/// forcibly aborting that event.
/// <returns>true if the script was successfully stopped, false otherwise</returns> /// <returns>true if the script was successfully stopped, false otherwise</returns>
bool Stop(int timeout); bool Stop(int timeout);
@ -169,8 +175,31 @@ namespace OpenSim.Region.ScriptEngine.Interfaces
object EventProcessor(); object EventProcessor();
int EventTime(); int EventTime();
void ResetScript();
/// <summary>
/// Reset the script.
/// </summary>
/// <remarks>
/// 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.
/// </remarks>
/// <param name='timeout'>
/// How many milliseconds we will wait for an existing script event to finish before
/// forcibly aborting that event prior to script reset.
/// </param>
void ResetScript(int timeout);
/// <summary>
/// Reset the script.
/// </summary>
/// <remarks>
/// 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.
/// </remarks>
void ApiResetScript(); void ApiResetScript();
Dictionary<string, object> GetVars(); Dictionary<string, object> GetVars();
void SetVars(Dictionary<string, object> vars); void SetVars(Dictionary<string, object> vars);
DetectParams GetDetectParams(int idx); DetectParams GetDetectParams(int idx);

View File

@ -877,7 +877,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
return (DateTime.Now - m_EventStart).Seconds; return (DateTime.Now - m_EventStart).Seconds;
} }
public void ResetScript() public void ResetScript(int timeout)
{ {
if (m_Script == null) if (m_Script == null)
return; return;
@ -887,7 +887,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
RemoveState(); RemoveState();
ReleaseControls(); ReleaseControls();
Stop(0); Stop(timeout);
SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID); SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID);
part.Inventory.GetInventoryItem(ItemID).PermsMask = 0; part.Inventory.GetInventoryItem(ItemID).PermsMask = 0;
part.Inventory.GetInventoryItem(ItemID).PermsGranter = UUID.Zero; part.Inventory.GetInventoryItem(ItemID).PermsGranter = UUID.Zero;

View File

@ -1691,7 +1691,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
{ {
IScriptInstance instance = GetInstance(itemID); IScriptInstance instance = GetInstance(itemID);
if (instance != null) if (instance != null)
instance.ResetScript(); instance.ResetScript(m_WaitForEventCompletionOnScriptStop);
} }
public void StartScript(UUID itemID) public void StartScript(UUID itemID)