diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Instance')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | 47 |
1 files changed, 27 insertions, 20 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index 660e9a3..5288cd3 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 |
@@ -431,14 +432,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
431 | { | 432 | { |
432 | int permsMask; | 433 | int permsMask; |
433 | UUID permsGranter; | 434 | UUID permsGranter; |
434 | lock (part.TaskInventory) | 435 | part.TaskInventory.LockItemsForRead(true); |
436 | if (!part.TaskInventory.ContainsKey(m_ItemID)) | ||
435 | { | 437 | { |
436 | if (!part.TaskInventory.ContainsKey(m_ItemID)) | 438 | part.TaskInventory.LockItemsForRead(false); |
437 | return; | 439 | return; |
438 | |||
439 | permsGranter = part.TaskInventory[m_ItemID].PermsGranter; | ||
440 | permsMask = part.TaskInventory[m_ItemID].PermsMask; | ||
441 | } | 440 | } |
441 | permsGranter = part.TaskInventory[m_ItemID].PermsGranter; | ||
442 | permsMask = part.TaskInventory[m_ItemID].PermsMask; | ||
443 | part.TaskInventory.LockItemsForRead(false); | ||
442 | 444 | ||
443 | if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) | 445 | if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) |
444 | { | 446 | { |
@@ -547,6 +549,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
547 | return true; | 549 | return true; |
548 | } | 550 | } |
549 | 551 | ||
552 | [DebuggerNonUserCode] //Prevents the debugger from farting in this function | ||
550 | public void SetState(string state) | 553 | public void SetState(string state) |
551 | { | 554 | { |
552 | if (state == State) | 555 | if (state == State) |
@@ -558,7 +561,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
558 | new DetectParams[0])); | 561 | new DetectParams[0])); |
559 | PostEvent(new EventParams("state_entry", new Object[0], | 562 | PostEvent(new EventParams("state_entry", new Object[0], |
560 | new DetectParams[0])); | 563 | new DetectParams[0])); |
561 | 564 | ||
562 | throw new EventAbortException(); | 565 | throw new EventAbortException(); |
563 | } | 566 | } |
564 | 567 | ||
@@ -641,14 +644,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
641 | /// <returns></returns> | 644 | /// <returns></returns> |
642 | public object EventProcessor() | 645 | public object EventProcessor() |
643 | { | 646 | { |
644 | if (m_Suspended) | 647 | EventParams data = null; |
645 | return 0; | ||
646 | 648 | ||
647 | lock (m_Script) | 649 | lock (m_EventQueue) |
648 | { | 650 | { |
649 | EventParams data = null; | 651 | if (m_Suspended) |
652 | return 0; | ||
650 | 653 | ||
651 | lock (m_EventQueue) | 654 | lock (m_Script) |
652 | { | 655 | { |
653 | data = (EventParams) m_EventQueue.Dequeue(); | 656 | data = (EventParams) m_EventQueue.Dequeue(); |
654 | if (data == null) // Shouldn't happen | 657 | if (data == null) // Shouldn't happen |
@@ -674,6 +677,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
674 | if (data.EventName == "collision") | 677 | if (data.EventName == "collision") |
675 | m_CollisionInQueue = false; | 678 | m_CollisionInQueue = false; |
676 | } | 679 | } |
680 | } | ||
681 | lock(m_Script) | ||
682 | { | ||
677 | 683 | ||
678 | //m_log.DebugFormat("[XENGINE]: Processing event {0} for {1}", data.EventName, this); | 684 | //m_log.DebugFormat("[XENGINE]: Processing event {0} for {1}", data.EventName, this); |
679 | 685 | ||
@@ -830,6 +836,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
830 | new Object[0], new DetectParams[0])); | 836 | new Object[0], new DetectParams[0])); |
831 | } | 837 | } |
832 | 838 | ||
839 | [DebuggerNonUserCode] //Stops the VS debugger from farting in this function | ||
833 | public void ApiResetScript() | 840 | public void ApiResetScript() |
834 | { | 841 | { |
835 | // bool running = Running; | 842 | // bool running = Running; |