diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Instance')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | 52 |
1 files changed, 28 insertions, 24 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index 6e9f3ec..cf25189 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; |
@@ -238,13 +239,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
238 | 239 | ||
239 | if (part != null) | 240 | if (part != null) |
240 | { | 241 | { |
241 | lock (part.TaskInventory) | 242 | part.TaskInventory.LockItemsForRead(true); |
243 | if (part.TaskInventory.ContainsKey(m_ItemID)) | ||
242 | { | 244 | { |
243 | if (part.TaskInventory.ContainsKey(m_ItemID)) | 245 | m_thisScriptTask = part.TaskInventory[m_ItemID]; |
244 | { | ||
245 | m_thisScriptTask = part.TaskInventory[m_ItemID]; | ||
246 | } | ||
247 | } | 246 | } |
247 | part.TaskInventory.LockItemsForRead(false); | ||
248 | } | 248 | } |
249 | 249 | ||
250 | ApiManager am = new ApiManager(); | 250 | ApiManager am = new ApiManager(); |
@@ -271,9 +271,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
271 | //RemotingServices.GetLifetimeService(m_Script as ScriptBaseClass); | 271 | //RemotingServices.GetLifetimeService(m_Script as ScriptBaseClass); |
272 | // lease.Register(this); | 272 | // lease.Register(this); |
273 | } | 273 | } |
274 | catch (Exception) | 274 | catch (Exception e) |
275 | { | 275 | { |
276 | // m_log.ErrorFormat("[Script] Error loading assembly {0}\n"+e.ToString(), assembly); | 276 | m_log.ErrorFormat("[Script] Error loading assembly {0}\n"+e.ToString(), assembly); |
277 | throw; | ||
277 | } | 278 | } |
278 | 279 | ||
279 | try | 280 | try |
@@ -434,14 +435,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
434 | { | 435 | { |
435 | int permsMask; | 436 | int permsMask; |
436 | UUID permsGranter; | 437 | UUID permsGranter; |
437 | lock (part.TaskInventory) | 438 | part.TaskInventory.LockItemsForRead(true); |
439 | if (!part.TaskInventory.ContainsKey(m_ItemID)) | ||
438 | { | 440 | { |
439 | if (!part.TaskInventory.ContainsKey(m_ItemID)) | 441 | part.TaskInventory.LockItemsForRead(false); |
440 | return; | 442 | return; |
441 | |||
442 | permsGranter = part.TaskInventory[m_ItemID].PermsGranter; | ||
443 | permsMask = part.TaskInventory[m_ItemID].PermsMask; | ||
444 | } | 443 | } |
444 | permsGranter = part.TaskInventory[m_ItemID].PermsGranter; | ||
445 | permsMask = part.TaskInventory[m_ItemID].PermsMask; | ||
446 | part.TaskInventory.LockItemsForRead(false); | ||
445 | 447 | ||
446 | if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) | 448 | if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) |
447 | { | 449 | { |
@@ -550,6 +552,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
550 | return true; | 552 | return true; |
551 | } | 553 | } |
552 | 554 | ||
555 | [DebuggerNonUserCode] //Prevents the debugger from farting in this function | ||
553 | public void SetState(string state) | 556 | public void SetState(string state) |
554 | { | 557 | { |
555 | if (state == State) | 558 | if (state == State) |
@@ -561,7 +564,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
561 | new DetectParams[0])); | 564 | new DetectParams[0])); |
562 | PostEvent(new EventParams("state_entry", new Object[0], | 565 | PostEvent(new EventParams("state_entry", new Object[0], |
563 | new DetectParams[0])); | 566 | new DetectParams[0])); |
564 | 567 | ||
565 | throw new EventAbortException(); | 568 | throw new EventAbortException(); |
566 | } | 569 | } |
567 | 570 | ||
@@ -644,14 +647,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
644 | /// <returns></returns> | 647 | /// <returns></returns> |
645 | public object EventProcessor() | 648 | public object EventProcessor() |
646 | { | 649 | { |
647 | if (m_Suspended) | 650 | EventParams data = null; |
648 | return 0; | ||
649 | 651 | ||
650 | lock (m_Script) | 652 | lock (m_EventQueue) |
651 | { | 653 | { |
652 | EventParams data = null; | 654 | if (m_Suspended) |
655 | return 0; | ||
653 | 656 | ||
654 | lock (m_EventQueue) | 657 | lock (m_Script) |
655 | { | 658 | { |
656 | data = (EventParams) m_EventQueue.Dequeue(); | 659 | data = (EventParams) m_EventQueue.Dequeue(); |
657 | if (data == null) // Shouldn't happen | 660 | if (data == null) // Shouldn't happen |
@@ -677,6 +680,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
677 | if (data.EventName == "collision") | 680 | if (data.EventName == "collision") |
678 | m_CollisionInQueue = false; | 681 | m_CollisionInQueue = false; |
679 | } | 682 | } |
683 | } | ||
684 | lock(m_Script) | ||
685 | { | ||
680 | 686 | ||
681 | //m_log.DebugFormat("[XENGINE]: Processing event {0} for {1}", data.EventName, this); | 687 | //m_log.DebugFormat("[XENGINE]: Processing event {0} for {1}", data.EventName, this); |
682 | 688 | ||
@@ -833,6 +839,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
833 | new Object[0], new DetectParams[0])); | 839 | new Object[0], new DetectParams[0])); |
834 | } | 840 | } |
835 | 841 | ||
842 | [DebuggerNonUserCode] //Stops the VS debugger from farting in this function | ||
836 | public void ApiResetScript() | 843 | public void ApiResetScript() |
837 | { | 844 | { |
838 | // bool running = Running; | 845 | // bool running = Running; |
@@ -864,10 +871,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
864 | 871 | ||
865 | public Dictionary<string, object> GetVars() | 872 | public Dictionary<string, object> GetVars() |
866 | { | 873 | { |
867 | if (m_Script != null) | 874 | return m_Script.GetVars(); |
868 | return m_Script.GetVars(); | ||
869 | else | ||
870 | return new Dictionary<string, object>(); | ||
871 | } | 875 | } |
872 | 876 | ||
873 | public void SetVars(Dictionary<string, object> vars) | 877 | public void SetVars(Dictionary<string, object> vars) |