Merge commit '5607fd3af828846291de3358067bb1214619489e' into bigmerge

Conflicts:
	OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
	OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
avinationmerge
Melanie 2011-10-25 03:16:26 +01:00
commit 85d40ce1d1
2 changed files with 54 additions and 22 deletions

View File

@ -139,7 +139,31 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
set { m_RunEvents = value; } 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 public bool ShuttingDown
{ {
@ -650,38 +674,38 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
{ {
EventParams data = null; EventParams data = null;
// m_log.DebugFormat("[XEngine]: EventProcessor() invoked for {0}.{1}", PrimName, ScriptName);
if (Suspended) if (Suspended)
return 0; return 0;
lock (m_EventQueue) lock (m_EventQueue)
{ {
lock (m_Script) data = (EventParams) m_EventQueue.Dequeue();
if (data == null) // Shouldn't happen
{ {
data = (EventParams) m_EventQueue.Dequeue(); if ((m_EventQueue.Count > 0) && m_RunEvents && (!m_ShuttingDown))
if (data == null) // Shouldn't happen
{ {
if ((m_EventQueue.Count > 0) && m_RunEvents && (!m_ShuttingDown)) m_CurrentResult = m_Engine.QueueEventHandler(this);
{
m_CurrentResult = m_Engine.QueueEventHandler(this);
}
else
{
m_CurrentResult = null;
}
return 0;
} }
else
if (data.EventName == "timer")
m_TimerQueued = false;
if (data.EventName == "control")
{ {
if (m_ControlEventsInQueue > 0) m_CurrentResult = null;
m_ControlEventsInQueue--;
} }
if (data.EventName == "collision") return 0;
m_CollisionInQueue = false;
} }
if (data.EventName == "timer")
m_TimerQueued = false;
if (data.EventName == "control")
{
if (m_ControlEventsInQueue > 0)
m_ControlEventsInQueue--;
}
if (data.EventName == "collision")
m_CollisionInQueue = false;
} }
lock(m_Script) lock(m_Script)
{ {
@ -693,7 +717,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
{ {
// m_log.DebugFormat("[Script] Script {0}.{1} state set to {2}", // m_log.DebugFormat("[Script] Script {0}.{1} state set to {2}",
// m_PrimName, m_ScriptName, data.Params[0].ToString()); // m_PrimName, m_ScriptName, data.Params[0].ToString());
m_State=data.Params[0].ToString(); m_State = data.Params[0].ToString();
AsyncCommandManager.RemoveScript(m_Engine, AsyncCommandManager.RemoveScript(m_Engine,
m_LocalID, m_ItemID); m_LocalID, m_ItemID);

View File

@ -1009,7 +1009,15 @@ namespace OpenSim.Region.ScriptEngine.XEngine
// Do we even have it? // Do we even have it?
if (!m_Scripts.ContainsKey(itemID)) if (!m_Scripts.ContainsKey(itemID))
{ {
// Do we even have it?
if (!m_Scripts.ContainsKey(itemID))
return;
lockScriptsForRead(false); lockScriptsForRead(false);
lockScriptsForWrite(true);
m_Scripts.Remove(itemID);
lockScriptsForWrite(false);
return; return;
} }