diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | 50 |
1 files changed, 26 insertions, 24 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index 893f3ef..17c06e7 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.IO; | 29 | using System.IO; |
30 | using System.Diagnostics; //for [DebuggerNonUserCode] | ||
30 | using System.Runtime.Remoting; | 31 | using System.Runtime.Remoting; |
31 | using System.Runtime.Remoting.Lifetime; | 32 | using System.Runtime.Remoting.Lifetime; |
32 | using System.Threading; | 33 | using System.Threading; |
@@ -55,7 +56,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
55 | { | 56 | { |
56 | public class ScriptInstance : MarshalByRefObject, IScriptInstance | 57 | public class ScriptInstance : MarshalByRefObject, IScriptInstance |
57 | { | 58 | { |
58 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 59 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
59 | 60 | ||
60 | private IScriptEngine m_Engine; | 61 | private IScriptEngine m_Engine; |
61 | private IScriptWorkItem m_CurrentResult = null; | 62 | private IScriptWorkItem m_CurrentResult = null; |
@@ -239,13 +240,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
239 | 240 | ||
240 | if (part != null) | 241 | if (part != null) |
241 | { | 242 | { |
242 | lock (part.TaskInventory) | 243 | part.TaskInventory.LockItemsForRead(true); |
244 | if (part.TaskInventory.ContainsKey(m_ItemID)) | ||
243 | { | 245 | { |
244 | if (part.TaskInventory.ContainsKey(m_ItemID)) | 246 | m_thisScriptTask = part.TaskInventory[m_ItemID]; |
245 | { | ||
246 | m_thisScriptTask = part.TaskInventory[m_ItemID]; | ||
247 | } | ||
248 | } | 247 | } |
248 | part.TaskInventory.LockItemsForRead(false); | ||
249 | } | 249 | } |
250 | 250 | ||
251 | ApiManager am = new ApiManager(); | 251 | ApiManager am = new ApiManager(); |
@@ -272,9 +272,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
272 | //RemotingServices.GetLifetimeService(m_Script as ScriptBaseClass); | 272 | //RemotingServices.GetLifetimeService(m_Script as ScriptBaseClass); |
273 | // lease.Register(this); | 273 | // lease.Register(this); |
274 | } | 274 | } |
275 | catch (Exception) | 275 | catch (Exception e) |
276 | { | 276 | { |
277 | // m_log.ErrorFormat("[Script] Error loading assembly {0}\n"+e.ToString(), assembly); | 277 | m_log.ErrorFormat("[Script] Error loading assembly {0}\n"+e.ToString(), assembly); |
278 | throw; | ||
278 | } | 279 | } |
279 | 280 | ||
280 | try | 281 | try |
@@ -435,14 +436,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
435 | { | 436 | { |
436 | int permsMask; | 437 | int permsMask; |
437 | UUID permsGranter; | 438 | UUID permsGranter; |
438 | lock (part.TaskInventory) | 439 | part.TaskInventory.LockItemsForRead(true); |
440 | if (!part.TaskInventory.ContainsKey(m_ItemID)) | ||
439 | { | 441 | { |
440 | if (!part.TaskInventory.ContainsKey(m_ItemID)) | 442 | part.TaskInventory.LockItemsForRead(false); |
441 | return; | 443 | return; |
442 | |||
443 | permsGranter = part.TaskInventory[m_ItemID].PermsGranter; | ||
444 | permsMask = part.TaskInventory[m_ItemID].PermsMask; | ||
445 | } | 444 | } |
445 | permsGranter = part.TaskInventory[m_ItemID].PermsGranter; | ||
446 | permsMask = part.TaskInventory[m_ItemID].PermsMask; | ||
447 | part.TaskInventory.LockItemsForRead(false); | ||
446 | 448 | ||
447 | if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) | 449 | if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) |
448 | { | 450 | { |
@@ -551,6 +553,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
551 | return true; | 553 | return true; |
552 | } | 554 | } |
553 | 555 | ||
556 | [DebuggerNonUserCode] //Prevents the debugger from farting in this function | ||
554 | public void SetState(string state) | 557 | public void SetState(string state) |
555 | { | 558 | { |
556 | if (state == State) | 559 | if (state == State) |
@@ -562,7 +565,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
562 | new DetectParams[0])); | 565 | new DetectParams[0])); |
563 | PostEvent(new EventParams("state_entry", new Object[0], | 566 | PostEvent(new EventParams("state_entry", new Object[0], |
564 | new DetectParams[0])); | 567 | new DetectParams[0])); |
565 | 568 | ||
566 | throw new EventAbortException(); | 569 | throw new EventAbortException(); |
567 | } | 570 | } |
568 | 571 | ||
@@ -645,16 +648,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
645 | /// <returns></returns> | 648 | /// <returns></returns> |
646 | public object EventProcessor() | 649 | public object EventProcessor() |
647 | { | 650 | { |
648 | // m_log.DebugFormat("[XEngine]: EventProcessor() invoked for {0}.{1}", PrimName, ScriptName); | 651 | EventParams data = null; |
649 | 652 | ||
650 | if (Suspended) | 653 | if (Suspended) |
651 | return 0; | 654 | return 0; |
652 | 655 | ||
653 | lock (m_Script) | 656 | lock (m_EventQueue) |
654 | { | 657 | { |
655 | EventParams data = null; | 658 | lock (m_Script) |
656 | |||
657 | lock (m_EventQueue) | ||
658 | { | 659 | { |
659 | data = (EventParams) m_EventQueue.Dequeue(); | 660 | data = (EventParams) m_EventQueue.Dequeue(); |
660 | if (data == null) // Shouldn't happen | 661 | if (data == null) // Shouldn't happen |
@@ -680,6 +681,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
680 | if (data.EventName == "collision") | 681 | if (data.EventName == "collision") |
681 | m_CollisionInQueue = false; | 682 | m_CollisionInQueue = false; |
682 | } | 683 | } |
684 | } | ||
685 | lock(m_Script) | ||
686 | { | ||
683 | 687 | ||
684 | // m_log.DebugFormat("[XEngine]: Processing event {0} for {1}", data.EventName, this); | 688 | // m_log.DebugFormat("[XEngine]: Processing event {0} for {1}", data.EventName, this); |
685 | 689 | ||
@@ -836,6 +840,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
836 | new Object[0], new DetectParams[0])); | 840 | new Object[0], new DetectParams[0])); |
837 | } | 841 | } |
838 | 842 | ||
843 | [DebuggerNonUserCode] //Stops the VS debugger from farting in this function | ||
839 | public void ApiResetScript() | 844 | public void ApiResetScript() |
840 | { | 845 | { |
841 | // bool running = Running; | 846 | // bool running = Running; |
@@ -867,10 +872,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
867 | 872 | ||
868 | public Dictionary<string, object> GetVars() | 873 | public Dictionary<string, object> GetVars() |
869 | { | 874 | { |
870 | if (m_Script != null) | 875 | return m_Script.GetVars(); |
871 | return m_Script.GetVars(); | ||
872 | else | ||
873 | return new Dictionary<string, object>(); | ||
874 | } | 876 | } |
875 | 877 | ||
876 | public void SetVars(Dictionary<string, object> vars) | 878 | public void SetVars(Dictionary<string, object> vars) |