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 6663aa5..623cb7d 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 |
@@ -429,14 +430,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
429 | { | 430 | { |
430 | int permsMask; | 431 | int permsMask; |
431 | UUID permsGranter; | 432 | UUID permsGranter; |
432 | lock (part.TaskInventory) | 433 | part.TaskInventory.LockItemsForRead(true); |
434 | if (!part.TaskInventory.ContainsKey(m_ItemID)) | ||
433 | { | 435 | { |
434 | if (!part.TaskInventory.ContainsKey(m_ItemID)) | 436 | part.TaskInventory.LockItemsForRead(false); |
435 | return; | 437 | return; |
436 | |||
437 | permsGranter = part.TaskInventory[m_ItemID].PermsGranter; | ||
438 | permsMask = part.TaskInventory[m_ItemID].PermsMask; | ||
439 | } | 438 | } |
439 | permsGranter = part.TaskInventory[m_ItemID].PermsGranter; | ||
440 | permsMask = part.TaskInventory[m_ItemID].PermsMask; | ||
441 | part.TaskInventory.LockItemsForRead(false); | ||
440 | 442 | ||
441 | if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) | 443 | if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) |
442 | { | 444 | { |
@@ -545,6 +547,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
545 | return true; | 547 | return true; |
546 | } | 548 | } |
547 | 549 | ||
550 | [DebuggerNonUserCode] //Prevents the debugger from farting in this function | ||
548 | public void SetState(string state) | 551 | public void SetState(string state) |
549 | { | 552 | { |
550 | if (state == State) | 553 | if (state == State) |
@@ -556,7 +559,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
556 | new DetectParams[0])); | 559 | new DetectParams[0])); |
557 | PostEvent(new EventParams("state_entry", new Object[0], | 560 | PostEvent(new EventParams("state_entry", new Object[0], |
558 | new DetectParams[0])); | 561 | new DetectParams[0])); |
559 | 562 | ||
560 | throw new EventAbortException(); | 563 | throw new EventAbortException(); |
561 | } | 564 | } |
562 | 565 | ||
@@ -639,14 +642,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
639 | /// <returns></returns> | 642 | /// <returns></returns> |
640 | public object EventProcessor() | 643 | public object EventProcessor() |
641 | { | 644 | { |
642 | if (m_Suspended) | 645 | EventParams data = null; |
643 | return 0; | ||
644 | 646 | ||
645 | lock (m_Script) | 647 | lock (m_EventQueue) |
646 | { | 648 | { |
647 | EventParams data = null; | 649 | if (m_Suspended) |
650 | return 0; | ||
648 | 651 | ||
649 | lock (m_EventQueue) | 652 | lock (m_Script) |
650 | { | 653 | { |
651 | data = (EventParams) m_EventQueue.Dequeue(); | 654 | data = (EventParams) m_EventQueue.Dequeue(); |
652 | if (data == null) // Shouldn't happen | 655 | if (data == null) // Shouldn't happen |
@@ -672,6 +675,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
672 | if (data.EventName == "collision") | 675 | if (data.EventName == "collision") |
673 | m_CollisionInQueue = false; | 676 | m_CollisionInQueue = false; |
674 | } | 677 | } |
678 | } | ||
679 | lock(m_Script) | ||
680 | { | ||
675 | 681 | ||
676 | //m_log.DebugFormat("[XENGINE]: Processing event {0} for {1}", data.EventName, this); | 682 | //m_log.DebugFormat("[XENGINE]: Processing event {0} for {1}", data.EventName, this); |
677 | 683 | ||
@@ -828,6 +834,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
828 | new Object[0], new DetectParams[0])); | 834 | new Object[0], new DetectParams[0])); |
829 | } | 835 | } |
830 | 836 | ||
837 | [DebuggerNonUserCode] //Stops the VS debugger from farting in this function | ||
831 | public void ApiResetScript() | 838 | public void ApiResetScript() |
832 | { | 839 | { |
833 | // bool running = Running; | 840 | // bool running = Running; |