Fix resume scripts.
On resume, we need to place requeue the script for event processing if there are any events on the queue. Also need to do this under m_Script lock in order to avoid a race0.7.2-post-fixes
parent
8340bd7e20
commit
986ded5a72
|
@ -55,7 +55,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
|
|||
{
|
||||
public class ScriptInstance : MarshalByRefObject, IScriptInstance
|
||||
{
|
||||
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private IScriptEngine m_Engine;
|
||||
private IScriptWorkItem m_CurrentResult = null;
|
||||
|
@ -138,7 +138,31 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
|
|||
set { m_RunEvents = value; }
|
||||
}
|
||||
|
||||
public bool Suspended { get; set; }
|
||||
public bool Suspended
|
||||
{
|
||||
get { return m_Suspended; }
|
||||
|
||||
set
|
||||
{
|
||||
// Need to do this inside a lock in order to avoid races with EventProcessor()
|
||||
lock (m_Script)
|
||||
{
|
||||
bool wasSuspended = m_Suspended;
|
||||
m_Suspended = value;
|
||||
|
||||
if (wasSuspended && !m_Suspended)
|
||||
{
|
||||
lock (m_EventQueue)
|
||||
{
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private bool m_Suspended;
|
||||
|
||||
public bool ShuttingDown
|
||||
{
|
||||
|
@ -645,13 +669,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
|
|||
/// <returns></returns>
|
||||
public object EventProcessor()
|
||||
{
|
||||
// m_log.DebugFormat("[XEngine]: EventProcessor() invoked for {0}.{1}", PrimName, ScriptName);
|
||||
|
||||
if (Suspended)
|
||||
return 0;
|
||||
|
||||
lock (m_Script)
|
||||
{
|
||||
// m_log.DebugFormat("[XEngine]: EventProcessor() invoked for {0}.{1}", PrimName, ScriptName);
|
||||
|
||||
if (Suspended)
|
||||
return 0;
|
||||
|
||||
EventParams data = null;
|
||||
|
||||
lock (m_EventQueue)
|
||||
|
@ -689,7 +713,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
|
|||
{
|
||||
// m_log.DebugFormat("[Script] Script {0}.{1} state set to {2}",
|
||||
// m_PrimName, m_ScriptName, data.Params[0].ToString());
|
||||
m_State=data.Params[0].ToString();
|
||||
m_State = data.Params[0].ToString();
|
||||
AsyncCommandManager.RemoveScript(m_Engine,
|
||||
m_LocalID, m_ItemID);
|
||||
|
||||
|
|
|
@ -946,7 +946,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
|||
if (!m_Scripts.ContainsKey(itemID))
|
||||
return;
|
||||
|
||||
instance=m_Scripts[itemID];
|
||||
instance = m_Scripts[itemID];
|
||||
m_Scripts.Remove(itemID);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue