From 889ce36afa67c521f3e50e4833a894ffd39af490 Mon Sep 17 00:00:00 2001
From: CasperW
Date: Mon, 23 Nov 2009 16:02:05 +0100
Subject: Added some [DebuggerNonUserCode] modifiers to functions that throw
EventAbortException() to ease debugging on Visual Studio
---
OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 4 ++++
OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs | 2 ++
OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs | 2 ++
OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | 5 ++++-
OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 3 +++
5 files changed, 15 insertions(+), 1 deletion(-)
(limited to 'OpenSim/Region/ScriptEngine')
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 50b2fb5..b549b5c 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -28,6 +28,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
+using System.Diagnostics; //for [DebuggerNonUserCode]
using System.Runtime.Remoting.Lifetime;
using System.Text;
using System.Threading;
@@ -151,6 +152,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
get { return m_ScriptEngine.World; }
}
+ [DebuggerNonUserCode]
public void state(string newState)
{
m_ScriptEngine.SetState(m_itemID, newState);
@@ -160,6 +162,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
/// Reset the named script. The script must be present
/// in the same prim.
///
+ [DebuggerNonUserCode]
public void llResetScript()
{
m_host.AddScriptLPS(1);
@@ -3755,6 +3758,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
ScriptSleep(3000);
}
+ [DebuggerNonUserCode]
public void llRemoveInventory(string name)
{
m_host.AddScriptLPS(1);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs
index 7f67599..15e0408 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs
@@ -27,6 +27,7 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics; //for [DebuggerNonUserCode]
using System.Reflection;
using System.Runtime.Remoting.Lifetime;
using OpenSim.Region.ScriptEngine.Shared;
@@ -131,6 +132,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
return (eventFlags);
}
+ [DebuggerNonUserCode]
public void ExecuteEvent(string state, string FunctionName, object[] args)
{
// IMPORTANT: Types and MemberInfo-derived objects require a LOT of memory.
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs
index 121159c..a44abb0 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs
@@ -33,6 +33,7 @@ using System.Threading;
using System.Reflection;
using System.Collections;
using System.Collections.Generic;
+using System.Diagnostics; //for [DebuggerNonUserCode]
using OpenSim.Region.ScriptEngine.Interfaces;
using OpenSim.Region.ScriptEngine.Shared;
using OpenSim.Region.ScriptEngine.Shared.Api.Runtime;
@@ -90,6 +91,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
return (int)m_Executor.GetStateEventFlags(state);
}
+ [DebuggerNonUserCode]
public void ExecuteEvent(string state, string FunctionName, object[] args)
{
m_Executor.ExecuteEvent(state, FunctionName, args);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
index 41b5d49..ed3fdbe 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
@@ -27,6 +27,7 @@
using System;
using System.IO;
+using System.Diagnostics; //for [DebuggerNonUserCode]
using System.Runtime.Remoting;
using System.Runtime.Remoting.Lifetime;
using System.Threading;
@@ -544,6 +545,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
return true;
}
+ [DebuggerNonUserCode] //Prevents the debugger from farting in this function
public void SetState(string state)
{
if (state == State)
@@ -555,7 +557,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
new DetectParams[0]));
PostEvent(new EventParams("state_entry", new Object[0],
new DetectParams[0]));
-
+
throw new EventAbortException();
}
@@ -824,6 +826,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
new Object[0], new DetectParams[0]));
}
+ [DebuggerNonUserCode] //Stops the VS debugger from farting in this function
public void ApiResetScript()
{
// bool running = Running;
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index a60c0ba..8b94f28 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -30,6 +30,7 @@ using System.IO;
using System.Threading;
using System.Collections;
using System.Collections.Generic;
+using System.Diagnostics; //for [DebuggerNonUserCode]
using System.Security;
using System.Security.Policy;
using System.Reflection;
@@ -1119,6 +1120,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
return false;
}
+ [DebuggerNonUserCode]
public void ApiResetScript(UUID itemID)
{
IScriptInstance instance = GetInstance(itemID);
@@ -1170,6 +1172,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
return UUID.Zero;
}
+ [DebuggerNonUserCode]
public void SetState(UUID itemID, string newState)
{
IScriptInstance instance = GetInstance(itemID);
--
cgit v1.1
From 247c66b3fe792692468ede6a516d85c6c9852d23 Mon Sep 17 00:00:00 2001
From: CasperW
Date: Mon, 23 Nov 2009 20:25:53 +0100
Subject: Swap the locking of m_EventQueue and m_Script to ease locks on script
inventory operations
---
.../ScriptEngine/Shared/Instance/ScriptInstance.cs | 234 +++++++++++----------
1 file changed, 119 insertions(+), 115 deletions(-)
(limited to 'OpenSim/Region/ScriptEngine')
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
index ed3fdbe..063d50f 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
@@ -640,154 +640,158 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
///
public object EventProcessor()
{
+
+ EventParams data = null;
+
+ lock (m_EventQueue)
+ {
lock (m_Script)
{
- EventParams data = null;
-
- lock (m_EventQueue)
+ data = (EventParams) m_EventQueue.Dequeue();
+ if (data == null) // Shouldn't happen
{
- data = (EventParams) m_EventQueue.Dequeue();
- if (data == null) // Shouldn't happen
+ if ((m_EventQueue.Count > 0) && m_RunEvents && (!m_ShuttingDown))
{
- if ((m_EventQueue.Count > 0) && m_RunEvents && (!m_ShuttingDown))
- {
- m_CurrentResult = m_Engine.QueueEventHandler(this);
- }
- else
- {
- m_CurrentResult = null;
- }
- return 0;
+ m_CurrentResult = m_Engine.QueueEventHandler(this);
}
-
- if (data.EventName == "timer")
- m_TimerQueued = false;
- if (data.EventName == "control")
+ else
{
- if (m_ControlEventsInQueue > 0)
- m_ControlEventsInQueue--;
+ m_CurrentResult = null;
}
- if (data.EventName == "collision")
- m_CollisionInQueue = false;
+ return 0;
}
-
- //m_log.DebugFormat("[XENGINE]: Processing event {0} for {1}", data.EventName, this);
- m_DetectParams = data.DetectParams;
-
- if (data.EventName == "state") // Hardcoded state change
+ if (data.EventName == "timer")
+ m_TimerQueued = false;
+ if (data.EventName == "control")
{
- // m_log.DebugFormat("[Script] Script {0}.{1} state set to {2}",
- // m_PrimName, m_ScriptName, data.Params[0].ToString());
- m_State=data.Params[0].ToString();
- AsyncCommandManager.RemoveScript(m_Engine,
- m_LocalID, m_ItemID);
+ if (m_ControlEventsInQueue > 0)
+ m_ControlEventsInQueue--;
+ }
+ if (data.EventName == "collision")
+ m_CollisionInQueue = false;
+ }
+ }
+ lock(m_Script)
+ {
+
+ //m_log.DebugFormat("[XENGINE]: Processing event {0} for {1}", data.EventName, this);
- SceneObjectPart part = m_Engine.World.GetSceneObjectPart(
- m_LocalID);
- if (part != null)
- {
- part.SetScriptEvents(m_ItemID,
- (int)m_Script.GetStateEventFlags(State));
- }
+ m_DetectParams = data.DetectParams;
+
+ if (data.EventName == "state") // Hardcoded state change
+ {
+// m_log.DebugFormat("[Script] Script {0}.{1} state set to {2}",
+// m_PrimName, m_ScriptName, data.Params[0].ToString());
+ m_State=data.Params[0].ToString();
+ AsyncCommandManager.RemoveScript(m_Engine,
+ m_LocalID, m_ItemID);
+
+ SceneObjectPart part = m_Engine.World.GetSceneObjectPart(
+ m_LocalID);
+ if (part != null)
+ {
+ part.SetScriptEvents(m_ItemID,
+ (int)m_Script.GetStateEventFlags(State));
}
- else
+ }
+ else
+ {
+ if (m_Engine.World.PipeEventsForScript(m_LocalID) ||
+ data.EventName == "control") // Don't freeze avies!
{
- if (m_Engine.World.PipeEventsForScript(m_LocalID) ||
- data.EventName == "control") // Don't freeze avies!
- {
- SceneObjectPart part = m_Engine.World.GetSceneObjectPart(
- m_LocalID);
- // m_log.DebugFormat("[Script] Delivered event {2} in state {3} to {0}.{1}",
- // m_PrimName, m_ScriptName, data.EventName, m_State);
+ SceneObjectPart part = m_Engine.World.GetSceneObjectPart(
+ m_LocalID);
+ // m_log.DebugFormat("[Script] Delivered event {2} in state {3} to {0}.{1}",
+ // m_PrimName, m_ScriptName, data.EventName, m_State);
- try
- {
- m_CurrentEvent = data.EventName;
- m_EventStart = DateTime.Now;
- m_InEvent = true;
+ try
+ {
+ m_CurrentEvent = data.EventName;
+ m_EventStart = DateTime.Now;
+ m_InEvent = true;
- m_Script.ExecuteEvent(State, data.EventName, data.Params);
+ m_Script.ExecuteEvent(State, data.EventName, data.Params);
- m_InEvent = false;
- m_CurrentEvent = String.Empty;
+ m_InEvent = false;
+ m_CurrentEvent = String.Empty;
- if (m_SaveState)
- {
- // This will be the very first event we deliver
- // (state_entry) in default state
- //
+ if (m_SaveState)
+ {
+ // This will be the very first event we deliver
+ // (state_entry) in default state
+ //
- SaveState(m_Assembly);
+ SaveState(m_Assembly);
- m_SaveState = false;
- }
+ m_SaveState = false;
}
- catch (Exception e)
- {
- // m_log.DebugFormat("[SCRIPT] Exception: {0}", e.Message);
- m_InEvent = false;
- m_CurrentEvent = String.Empty;
+ }
+ catch (Exception e)
+ {
+ // m_log.DebugFormat("[SCRIPT] Exception: {0}", e.Message);
+ m_InEvent = false;
+ m_CurrentEvent = String.Empty;
- if ((!(e is TargetInvocationException) || (!(e.InnerException is SelfDeleteException) && !(e.InnerException is ScriptDeleteException))) && !(e is ThreadAbortException))
- {
- try
- {
- // DISPLAY ERROR INWORLD
- string text = FormatException(e);
-
- if (text.Length > 1000)
- text = text.Substring(0, 1000);
- m_Engine.World.SimChat(Utils.StringToBytes(text),
- ChatTypeEnum.DebugChannel, 2147483647,
- part.AbsolutePosition,
- part.Name, part.UUID, false);
- }
- catch (Exception)
- {
- }
- // catch (Exception e2) // LEGIT: User Scripting
- // {
- // m_log.Error("[SCRIPT]: "+
- // "Error displaying error in-world: " +
- // e2.ToString());
- // m_log.Error("[SCRIPT]: " +
- // "Errormessage: Error compiling script:\r\n" +
- // e.ToString());
- // }
- }
- else if ((e is TargetInvocationException) && (e.InnerException is SelfDeleteException))
+ if ((!(e is TargetInvocationException) || (!(e.InnerException is SelfDeleteException) && !(e.InnerException is ScriptDeleteException))) && !(e is ThreadAbortException))
+ {
+ try
{
- m_InSelfDelete = true;
- if (part != null && part.ParentGroup != null)
- m_Engine.World.DeleteSceneObject(part.ParentGroup, false);
+ // DISPLAY ERROR INWORLD
+ string text = FormatException(e);
+
+ if (text.Length > 1000)
+ text = text.Substring(0, 1000);
+ m_Engine.World.SimChat(Utils.StringToBytes(text),
+ ChatTypeEnum.DebugChannel, 2147483647,
+ part.AbsolutePosition,
+ part.Name, part.UUID, false);
}
- else if ((e is TargetInvocationException) && (e.InnerException is ScriptDeleteException))
+ catch (Exception)
{
- m_InSelfDelete = true;
- if (part != null && part.ParentGroup != null)
- part.Inventory.RemoveInventoryItem(m_ItemID);
}
+ // catch (Exception e2) // LEGIT: User Scripting
+ // {
+ // m_log.Error("[SCRIPT]: "+
+ // "Error displaying error in-world: " +
+ // e2.ToString());
+ // m_log.Error("[SCRIPT]: " +
+ // "Errormessage: Error compiling script:\r\n" +
+ // e.ToString());
+ // }
+ }
+ else if ((e is TargetInvocationException) && (e.InnerException is SelfDeleteException))
+ {
+ m_InSelfDelete = true;
+ if (part != null && part.ParentGroup != null)
+ m_Engine.World.DeleteSceneObject(part.ParentGroup, false);
+ }
+ else if ((e is TargetInvocationException) && (e.InnerException is ScriptDeleteException))
+ {
+ m_InSelfDelete = true;
+ if (part != null && part.ParentGroup != null)
+ part.Inventory.RemoveInventoryItem(m_ItemID);
}
}
}
+ }
- lock (m_EventQueue)
+ lock (m_EventQueue)
+ {
+ if ((m_EventQueue.Count > 0) && m_RunEvents && (!m_ShuttingDown))
{
- if ((m_EventQueue.Count > 0) && m_RunEvents && (!m_ShuttingDown))
- {
- m_CurrentResult = m_Engine.QueueEventHandler(this);
- }
- else
- {
- m_CurrentResult = null;
- }
+ m_CurrentResult = m_Engine.QueueEventHandler(this);
+ }
+ else
+ {
+ m_CurrentResult = null;
}
+ }
- m_DetectParams = null;
+ m_DetectParams = null;
- return 0;
- }
+ return 0;
+ }
}
public int EventTime()
--
cgit v1.1
From d1147136946daf14724183b3191119be44ff8b16 Mon Sep 17 00:00:00 2001
From: CasperW
Date: Tue, 24 Nov 2009 18:02:12 +0100
Subject: Drop all locking of part.TaskInventory in favour of a
ReaderWriterLockSlim lock handler. This gives us: - Faster prim inventory
actions. Multiple threads can read at once. - Fixes the known prim inventory
thread locks - In the event of a thread lock occurring, it will usually self
heal after sixty seconds with an error message in the console
---
.../Shared/Api/Implementation/LSL_Api.cs | 532 ++++++++++++---------
.../Shared/Api/Implementation/OSSL_Api.cs | 36 +-
.../ScriptEngine/Shared/Instance/ScriptInstance.cs | 22 +-
3 files changed, 334 insertions(+), 256 deletions(-)
(limited to 'OpenSim/Region/ScriptEngine')
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index b549b5c..a94cd46 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -275,40 +275,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
protected UUID InventorySelf()
{
UUID invItemID = new UUID();
-
- lock (m_host.TaskInventory)
+ bool unlock = false;
+ if (!m_host.TaskInventory.IsReadLockedByMe())
+ {
+ m_host.TaskInventory.LockItemsForRead(true);
+ unlock = true;
+ }
+ foreach (KeyValuePair inv in m_host.TaskInventory)
{
- foreach (KeyValuePair inv in m_host.TaskInventory)
+ if (inv.Value.Type == 10 && inv.Value.ItemID == m_itemID)
{
- if (inv.Value.Type == 10 && inv.Value.ItemID == m_itemID)
- {
- invItemID = inv.Key;
- break;
- }
+ invItemID = inv.Key;
+ break;
}
}
-
+ if (unlock)
+ {
+ m_host.TaskInventory.LockItemsForRead(false);
+ }
return invItemID;
}
protected UUID InventoryKey(string name, int type)
{
m_host.AddScriptLPS(1);
-
- lock (m_host.TaskInventory)
+ m_host.TaskInventory.LockItemsForRead(true);
+
+ foreach (KeyValuePair inv in m_host.TaskInventory)
{
- foreach (KeyValuePair inv in m_host.TaskInventory)
+ if (inv.Value.Name == name)
{
- if (inv.Value.Name == name)
+ m_host.TaskInventory.LockItemsForRead(false);
+
+ if (inv.Value.Type != type)
{
- if (inv.Value.Type != type)
- return UUID.Zero;
-
- return inv.Value.AssetID;
+ return UUID.Zero;
}
+
+ return inv.Value.AssetID;
}
}
+ m_host.TaskInventory.LockItemsForRead(false);
return UUID.Zero;
}
@@ -316,17 +324,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
m_host.AddScriptLPS(1);
- lock (m_host.TaskInventory)
+
+ m_host.TaskInventory.LockItemsForRead(true);
+
+ foreach (KeyValuePair inv in m_host.TaskInventory)
{
- foreach (KeyValuePair inv in m_host.TaskInventory)
+ if (inv.Value.Name == name)
{
- if (inv.Value.Name == name)
- {
- return inv.Value.AssetID;
- }
+ m_host.TaskInventory.LockItemsForRead(false);
+ return inv.Value.AssetID;
}
}
+ m_host.TaskInventory.LockItemsForRead(false);
+
+
return UUID.Zero;
}
@@ -2537,12 +2549,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_host.AddScriptLPS(1);
+ m_host.TaskInventory.LockItemsForRead(true);
TaskInventoryItem item = m_host.TaskInventory[invItemID];
-
- lock (m_host.TaskInventory)
- {
- item = m_host.TaskInventory[invItemID];
- }
+ m_host.TaskInventory.LockItemsForRead(false);
if (item.PermsGranter == UUID.Zero)
return 0;
@@ -2617,6 +2626,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (dist > m_ScriptDistanceFactor * 10.0f)
return;
+ //Clone is thread-safe
TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone();
foreach (KeyValuePair inv in partInventory)
@@ -2750,13 +2760,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
TaskInventoryItem item;
- lock (m_host.TaskInventory)
+ m_host.TaskInventory.LockItemsForRead(true);
+ if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
{
- if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
- return;
- else
- item = m_host.TaskInventory[InventorySelf()];
+ m_host.TaskInventory.LockItemsForRead(false);
+ return;
+ }
+ else
+ {
+ item = m_host.TaskInventory[InventorySelf()];
}
+ m_host.TaskInventory.LockItemsForRead(false);
if (item.PermsGranter != UUID.Zero)
{
@@ -2778,13 +2792,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
TaskInventoryItem item;
+ m_host.TaskInventory.LockItemsForRead(true);
lock (m_host.TaskInventory)
{
+
if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
+ {
+ m_host.TaskInventory.LockItemsForRead(false);
return;
+ }
else
+ {
item = m_host.TaskInventory[InventorySelf()];
+ }
}
+ m_host.TaskInventory.LockItemsForRead(false);
m_host.AddScriptLPS(1);
@@ -2821,14 +2843,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
TaskInventoryItem item;
- lock (m_host.TaskInventory)
+ m_host.TaskInventory.LockItemsForRead(true);
+
+ if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
{
- if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
- return;
- else
- item = m_host.TaskInventory[InventorySelf()];
+ m_host.TaskInventory.LockItemsForRead(false);
+ return;
+ }
+ else
+ {
+ item = m_host.TaskInventory[InventorySelf()];
}
+ m_host.TaskInventory.LockItemsForRead(false);
+
if (item.PermsGranter != m_host.OwnerID)
return;
@@ -2853,13 +2881,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
TaskInventoryItem item;
- lock (m_host.TaskInventory)
+ m_host.TaskInventory.LockItemsForRead(true);
+
+ if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
{
- if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
- return;
- else
- item = m_host.TaskInventory[InventorySelf()];
+ m_host.TaskInventory.LockItemsForRead(false);
+ return;
+ }
+ else
+ {
+ item = m_host.TaskInventory[InventorySelf()];
}
+ m_host.TaskInventory.LockItemsForRead(false);
+
if (item.PermsGranter != m_host.OwnerID)
return;
@@ -3083,14 +3117,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
TaskInventoryItem item;
- lock (m_host.TaskInventory)
+ m_host.TaskInventory.LockItemsForRead(true);
+ if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
{
- if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
- return;
- else
- item = m_host.TaskInventory[InventorySelf()];
+ m_host.TaskInventory.LockItemsForRead(false);
+ return;
}
-
+ else
+ {
+ item = m_host.TaskInventory[InventorySelf()];
+ }
+ m_host.TaskInventory.LockItemsForRead(false);
if (item.PermsGranter == UUID.Zero)
return;
@@ -3120,13 +3157,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
TaskInventoryItem item;
- lock (m_host.TaskInventory)
+ m_host.TaskInventory.LockItemsForRead(true);
+ if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
{
- if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
- return;
- else
- item = m_host.TaskInventory[InventorySelf()];
+ m_host.TaskInventory.LockItemsForRead(false);
+ return;
}
+ else
+ {
+ item = m_host.TaskInventory[InventorySelf()];
+ }
+ m_host.TaskInventory.LockItemsForRead(false);
+
if (item.PermsGranter == UUID.Zero)
return;
@@ -3199,10 +3241,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
TaskInventoryItem item;
- lock (m_host.TaskInventory)
+
+ m_host.TaskInventory.LockItemsForRead(true);
+ if (!m_host.TaskInventory.ContainsKey(invItemID))
+ {
+ m_host.TaskInventory.LockItemsForRead(false);
+ return;
+ }
+ else
{
item = m_host.TaskInventory[invItemID];
}
+ m_host.TaskInventory.LockItemsForRead(false);
if (agentID == UUID.Zero || perm == 0) // Releasing permissions
{
@@ -3234,11 +3284,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms
{
- lock (m_host.TaskInventory)
- {
- m_host.TaskInventory[invItemID].PermsGranter = agentID;
- m_host.TaskInventory[invItemID].PermsMask = perm;
- }
+ m_host.TaskInventory.LockItemsForWrite(true);
+ m_host.TaskInventory[invItemID].PermsGranter = agentID;
+ m_host.TaskInventory[invItemID].PermsMask = perm;
+ m_host.TaskInventory.LockItemsForWrite(false);
m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
"run_time_permissions", new Object[] {
@@ -3258,11 +3307,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms
{
- lock (m_host.TaskInventory)
- {
- m_host.TaskInventory[invItemID].PermsGranter = agentID;
- m_host.TaskInventory[invItemID].PermsMask = perm;
- }
+ m_host.TaskInventory.LockItemsForWrite(true);
+ m_host.TaskInventory[invItemID].PermsGranter = agentID;
+ m_host.TaskInventory[invItemID].PermsMask = perm;
+ m_host.TaskInventory.LockItemsForWrite(false);
m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
"run_time_permissions", new Object[] {
@@ -3283,11 +3331,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (!m_waitingForScriptAnswer)
{
- lock (m_host.TaskInventory)
- {
- m_host.TaskInventory[invItemID].PermsGranter = agentID;
- m_host.TaskInventory[invItemID].PermsMask = 0;
- }
+ m_host.TaskInventory.LockItemsForWrite(true);
+ m_host.TaskInventory[invItemID].PermsGranter = agentID;
+ m_host.TaskInventory[invItemID].PermsMask = 0;
+ m_host.TaskInventory.LockItemsForWrite(false);
presence.ControllingClient.OnScriptAnswer += handleScriptAnswer;
m_waitingForScriptAnswer=true;
@@ -3322,10 +3369,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0)
llReleaseControls();
- lock (m_host.TaskInventory)
- {
- m_host.TaskInventory[invItemID].PermsMask = answer;
- }
+
+ m_host.TaskInventory.LockItemsForWrite(true);
+ m_host.TaskInventory[invItemID].PermsMask = answer;
+ m_host.TaskInventory.LockItemsForWrite(false);
+
m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
"run_time_permissions", new Object[] {
@@ -3337,16 +3385,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
m_host.AddScriptLPS(1);
- lock (m_host.TaskInventory)
+ m_host.TaskInventory.LockItemsForRead(true);
+
+ foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
{
- foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
+ if (item.Type == 10 && item.ItemID == m_itemID)
{
- if (item.Type == 10 && item.ItemID == m_itemID)
- {
- return item.PermsGranter.ToString();
- }
+ m_host.TaskInventory.LockItemsForRead(false);
+ return item.PermsGranter.ToString();
}
}
+ m_host.TaskInventory.LockItemsForRead(false);
return UUID.Zero.ToString();
}
@@ -3355,19 +3404,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
m_host.AddScriptLPS(1);
- lock (m_host.TaskInventory)
+ m_host.TaskInventory.LockItemsForRead(true);
+
+ foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
{
- foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
+ if (item.Type == 10 && item.ItemID == m_itemID)
{
- if (item.Type == 10 && item.ItemID == m_itemID)
- {
- int perms = item.PermsMask;
- if (m_automaticLinkPermission)
- perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS;
- return perms;
- }
+ int perms = item.PermsMask;
+ if (m_automaticLinkPermission)
+ perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS;
+ m_host.TaskInventory.LockItemsForRead(false);
+ return perms;
}
}
+ m_host.TaskInventory.LockItemsForRead(false);
return 0;
}
@@ -3400,11 +3450,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
UUID invItemID = InventorySelf();
TaskInventoryItem item;
- lock (m_host.TaskInventory)
- {
- item = m_host.TaskInventory[invItemID];
- }
-
+ m_host.TaskInventory.LockItemsForRead(true);
+ item = m_host.TaskInventory[invItemID];
+ m_host.TaskInventory.LockItemsForRead(false);
+
if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0
&& !m_automaticLinkPermission)
{
@@ -3457,16 +3506,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_host.AddScriptLPS(1);
UUID invItemID = InventorySelf();
- lock (m_host.TaskInventory)
- {
+ m_host.TaskInventory.LockItemsForRead(true);
if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0
&& !m_automaticLinkPermission)
{
ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!");
+ m_host.TaskInventory.LockItemsForRead(false);
return;
}
- }
-
+ m_host.TaskInventory.LockItemsForRead(false);
+
if (linknum < ScriptBaseClass.LINK_THIS)
return;
@@ -3635,17 +3684,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_host.AddScriptLPS(1);
int count = 0;
- lock (m_host.TaskInventory)
+ m_host.TaskInventory.LockItemsForRead(true);
+ foreach (KeyValuePair inv in m_host.TaskInventory)
{
- foreach (KeyValuePair inv in m_host.TaskInventory)
+ if (inv.Value.Type == type || type == -1)
{
- if (inv.Value.Type == type || type == -1)
- {
- count = count + 1;
- }
+ count = count + 1;
}
}
-
+
+ m_host.TaskInventory.LockItemsForRead(false);
return count;
}
@@ -3654,16 +3702,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_host.AddScriptLPS(1);
ArrayList keys = new ArrayList();
- lock (m_host.TaskInventory)
+ m_host.TaskInventory.LockItemsForRead(true);
+ foreach (KeyValuePair inv in m_host.TaskInventory)
{
- foreach (KeyValuePair inv in m_host.TaskInventory)
+ if (inv.Value.Type == type || type == -1)
{
- if (inv.Value.Type == type || type == -1)
- {
- keys.Add(inv.Value.Name);
- }
+ keys.Add(inv.Value.Name);
}
}
+ m_host.TaskInventory.LockItemsForRead(false);
if (keys.Count == 0)
{
@@ -3700,20 +3747,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
// move the first object found with this inventory name
- lock (m_host.TaskInventory)
+ m_host.TaskInventory.LockItemsForRead(true);
+ foreach (KeyValuePair inv in m_host.TaskInventory)
{
- foreach (KeyValuePair inv in m_host.TaskInventory)
+ if (inv.Value.Name == inventory)
{
- if (inv.Value.Name == inventory)
- {
- found = true;
- objId = inv.Key;
- assetType = inv.Value.Type;
- objName = inv.Value.Name;
- break;
- }
+ found = true;
+ objId = inv.Key;
+ assetType = inv.Value.Type;
+ objName = inv.Value.Name;
+ break;
}
}
+ m_host.TaskInventory.LockItemsForRead(false);
if (!found)
{
@@ -3763,20 +3809,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
m_host.AddScriptLPS(1);
- lock (m_host.TaskInventory)
+ m_host.TaskInventory.LockItemsForRead(true);
+ foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
{
- foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
+ if (item.Name == name)
{
- if (item.Name == name)
- {
- if (item.ItemID == m_itemID)
- throw new ScriptDeleteException();
- else
- m_host.Inventory.RemoveInventoryItem(item.ItemID);
- return;
- }
+ if (item.ItemID == m_itemID)
+ throw new ScriptDeleteException();
+ else
+ m_host.Inventory.RemoveInventoryItem(item.ItemID);
+
+ m_host.TaskInventory.LockItemsForRead(false);
+ return;
}
}
+ m_host.TaskInventory.LockItemsForRead(false);
}
public void llSetText(string text, LSL_Vector color, double alpha)
@@ -3865,6 +3912,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
m_host.AddScriptLPS(1);
+ //Clone is thread safe
TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone();
foreach (TaskInventoryItem item in itemDictionary.Values)
@@ -3955,17 +4003,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
UUID soundId = UUID.Zero;
if (!UUID.TryParse(impact_sound, out soundId))
{
- lock (m_host.TaskInventory)
+ m_host.TaskInventory.LockItemsForRead(true);
+ foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
{
- foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
+ if (item.Type == (int)AssetType.Sound && item.Name == impact_sound)
{
- if (item.Type == (int)AssetType.Sound && item.Name == impact_sound)
- {
- soundId = item.AssetID;
- break;
- }
+ soundId = item.AssetID;
+ break;
}
}
+ m_host.TaskInventory.LockItemsForRead(false);
}
m_host.CollisionSound = soundId;
m_host.CollisionSoundVolume = (float)impact_volume;
@@ -4011,6 +4058,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
UUID partItemID;
foreach (SceneObjectPart part in parts)
{
+ //Clone is thread safe
TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone();
foreach (TaskInventoryItem item in itemsDictionary.Values)
@@ -4218,17 +4266,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_host.AddScriptLPS(1);
- lock (m_host.TaskInventory)
+ m_host.TaskInventory.LockItemsForRead(true);
+ foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
{
- foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
+ if (item.Type == 10 && item.ItemID == m_itemID)
{
- if (item.Type == 10 && item.ItemID == m_itemID)
- {
- result = item.Name!=null?item.Name:String.Empty;
- break;
- }
+ result = item.Name!=null?item.Name:String.Empty;
+ break;
}
}
+ m_host.TaskInventory.LockItemsForRead(false);
return result;
}
@@ -4486,23 +4533,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
m_host.AddScriptLPS(1);
- lock (m_host.TaskInventory)
+ m_host.TaskInventory.LockItemsForRead(true);
+ foreach (KeyValuePair inv in m_host.TaskInventory)
{
- foreach (KeyValuePair inv in m_host.TaskInventory)
+ if (inv.Value.Name == name)
{
- if (inv.Value.Name == name)
+ if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify))
{
- if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify))
- {
- return inv.Value.AssetID.ToString();
- }
- else
- {
- return UUID.Zero.ToString();
- }
+ m_host.TaskInventory.LockItemsForRead(false);
+ return inv.Value.AssetID.ToString();
+ }
+ else
+ {
+ m_host.TaskInventory.LockItemsForRead(false);
+ return UUID.Zero.ToString();
}
}
}
+ m_host.TaskInventory.LockItemsForRead(false);
return UUID.Zero.ToString();
}
@@ -5997,14 +6045,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
protected UUID GetTaskInventoryItem(string name)
{
- lock (m_host.TaskInventory)
+ m_host.TaskInventory.LockItemsForRead(true);
+ foreach (KeyValuePair inv in m_host.TaskInventory)
{
- foreach (KeyValuePair inv in m_host.TaskInventory)
+ if (inv.Value.Name == name)
{
- if (inv.Value.Name == name)
- return inv.Key;
+ m_host.TaskInventory.LockItemsForRead(false);
+ return inv.Key;
}
}
+ m_host.TaskInventory.LockItemsForRead(false);
return UUID.Zero;
}
@@ -6315,22 +6365,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
// copy the first script found with this inventory name
- lock (m_host.TaskInventory)
+ m_host.TaskInventory.LockItemsForRead(true);
+ foreach (KeyValuePair inv in m_host.TaskInventory)
{
- foreach (KeyValuePair inv in m_host.TaskInventory)
+ if (inv.Value.Name == name)
{
- if (inv.Value.Name == name)
+ // make sure the object is a script
+ if (10 == inv.Value.Type)
{
- // make sure the object is a script
- if (10 == inv.Value.Type)
- {
- found = true;
- srcId = inv.Key;
- break;
- }
+ found = true;
+ srcId = inv.Key;
+ break;
}
}
}
+ m_host.TaskInventory.LockItemsForRead(false);
if (!found)
{
@@ -8133,28 +8182,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
m_host.AddScriptLPS(1);
- lock (m_host.TaskInventory)
+ m_host.TaskInventory.LockItemsForRead(true);
+ foreach (KeyValuePair inv in m_host.TaskInventory)
{
- foreach (KeyValuePair inv in m_host.TaskInventory)
+ if (inv.Value.Name == item)
{
- if (inv.Value.Name == item)
+ m_host.TaskInventory.LockItemsForRead(false);
+ switch (mask)
{
- switch (mask)
- {
- case 0:
- return (int)inv.Value.BasePermissions;
- case 1:
- return (int)inv.Value.CurrentPermissions;
- case 2:
- return (int)inv.Value.GroupPermissions;
- case 3:
- return (int)inv.Value.EveryonePermissions;
- case 4:
- return (int)inv.Value.NextPermissions;
- }
+ case 0:
+ return (int)inv.Value.BasePermissions;
+ case 1:
+ return (int)inv.Value.CurrentPermissions;
+ case 2:
+ return (int)inv.Value.GroupPermissions;
+ case 3:
+ return (int)inv.Value.EveryonePermissions;
+ case 4:
+ return (int)inv.Value.NextPermissions;
}
}
}
+ m_host.TaskInventory.LockItemsForRead(false);
return -1;
}
@@ -8169,16 +8218,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
m_host.AddScriptLPS(1);
- lock (m_host.TaskInventory)
+ m_host.TaskInventory.LockItemsForRead(true);
+ foreach (KeyValuePair inv in m_host.TaskInventory)
{
- foreach (KeyValuePair inv in m_host.TaskInventory)
+ if (inv.Value.Name == item)
{
- if (inv.Value.Name == item)
- {
- return inv.Value.CreatorID.ToString();
- }
+ m_host.TaskInventory.LockItemsForRead(false);
+ return inv.Value.CreatorID.ToString();
}
}
+ m_host.TaskInventory.LockItemsForRead(false);
llSay(0, "No item name '" + item + "'");
@@ -8702,16 +8751,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
m_host.AddScriptLPS(1);
- lock (m_host.TaskInventory)
+ m_host.TaskInventory.LockItemsForRead(true);
+ foreach (KeyValuePair inv in m_host.TaskInventory)
{
- foreach (KeyValuePair inv in m_host.TaskInventory)
+ if (inv.Value.Name == name)
{
- if (inv.Value.Name == name)
- {
- return inv.Value.Type;
- }
+ m_host.TaskInventory.LockItemsForRead(false);
+ return inv.Value.Type;
}
}
+ m_host.TaskInventory.LockItemsForRead(false);
return -1;
}
@@ -8742,17 +8791,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (invItemID == UUID.Zero)
return new LSL_Vector();
- lock (m_host.TaskInventory)
+ m_host.TaskInventory.LockItemsForRead(true);
+ if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero)
{
- if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero)
- return new LSL_Vector();
+ m_host.TaskInventory.LockItemsForRead(false);
+ return new LSL_Vector();
+ }
- if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
- {
- ShoutError("No permissions to track the camera");
- return new LSL_Vector();
- }
+ if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
+ {
+ ShoutError("No permissions to track the camera");
+ m_host.TaskInventory.LockItemsForRead(false);
+ return new LSL_Vector();
}
+ m_host.TaskInventory.LockItemsForRead(false);
ScenePresence presence = World.GetScenePresence(m_host.OwnerID);
if (presence != null)
@@ -8770,17 +8822,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (invItemID == UUID.Zero)
return new LSL_Rotation();
- lock (m_host.TaskInventory)
+ m_host.TaskInventory.LockItemsForRead(true);
+ if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero)
{
- if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero)
- return new LSL_Rotation();
-
- if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
- {
- ShoutError("No permissions to track the camera");
- return new LSL_Rotation();
- }
+ m_host.TaskInventory.LockItemsForRead(false);
+ return new LSL_Rotation();
}
+ if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
+ {
+ ShoutError("No permissions to track the camera");
+ m_host.TaskInventory.LockItemsForRead(false);
+ return new LSL_Rotation();
+ }
+ m_host.TaskInventory.LockItemsForRead(false);
ScenePresence presence = World.GetScenePresence(m_host.OwnerID);
if (presence != null)
@@ -8930,14 +8984,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (objectID == UUID.Zero) return;
UUID agentID;
- lock (m_host.TaskInventory)
- {
- // we need the permission first, to know which avatar we want to set the camera for
- agentID = m_host.TaskInventory[invItemID].PermsGranter;
+ m_host.TaskInventory.LockItemsForRead(true);
+ // we need the permission first, to know which avatar we want to set the camera for
+ agentID = m_host.TaskInventory[invItemID].PermsGranter;
- if (agentID == UUID.Zero) return;
- if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return;
+ if (agentID == UUID.Zero)
+ {
+ m_host.TaskInventory.LockItemsForRead(false);
+ return;
+ }
+ if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0)
+ {
+ m_host.TaskInventory.LockItemsForRead(false);
+ return;
}
+ m_host.TaskInventory.LockItemsForRead(false);
ScenePresence presence = World.GetScenePresence(agentID);
@@ -8987,12 +9048,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
// we need the permission first, to know which avatar we want to clear the camera for
UUID agentID;
- lock (m_host.TaskInventory)
+ m_host.TaskInventory.LockItemsForRead(true);
+ agentID = m_host.TaskInventory[invItemID].PermsGranter;
+ if (agentID == UUID.Zero)
{
- agentID = m_host.TaskInventory[invItemID].PermsGranter;
- if (agentID == UUID.Zero) return;
- if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return;
+ m_host.TaskInventory.LockItemsForRead(false);
+ return;
}
+ if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0)
+ {
+ m_host.TaskInventory.LockItemsForRead(false);
+ return;
+ }
+ m_host.TaskInventory.LockItemsForRead(false);
ScenePresence presence = World.GetScenePresence(agentID);
@@ -9449,15 +9517,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
internal UUID ScriptByName(string name)
{
- lock (m_host.TaskInventory)
+ m_host.TaskInventory.LockItemsForRead(true);
+
+ foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
{
- foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
+ if (item.Type == 10 && item.Name == name)
{
- if (item.Type == 10 && item.Name == name)
- return item.ItemID;
+ m_host.TaskInventory.LockItemsForRead(false);
+ return item.ItemID;
}
}
+ m_host.TaskInventory.LockItemsForRead(false);
+
return UUID.Zero;
}
@@ -9498,6 +9570,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
m_host.AddScriptLPS(1);
+ //Clone is thread safe
TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone();
UUID assetID = UUID.Zero;
@@ -9560,6 +9633,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
m_host.AddScriptLPS(1);
+ //Clone is thread safe
TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone();
UUID assetID = UUID.Zero;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 7fdbac8..83322eb 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -728,18 +728,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (target != null)
{
UUID animID=UUID.Zero;
- lock (m_host.TaskInventory)
+ m_host.TaskInventory.LockItemsForRead(true);
+ foreach (KeyValuePair inv in m_host.TaskInventory)
{
- foreach (KeyValuePair inv in m_host.TaskInventory)
+ if (inv.Value.Name == animation)
{
- if (inv.Value.Name == animation)
- {
- if (inv.Value.Type == (int)AssetType.Animation)
- animID = inv.Value.AssetID;
- continue;
- }
+ if (inv.Value.Type == (int)AssetType.Animation)
+ animID = inv.Value.AssetID;
+ continue;
}
}
+ m_host.TaskInventory.LockItemsForRead(false);
if (animID == UUID.Zero)
target.Animator.AddAnimation(animation, m_host.UUID);
else
@@ -761,18 +760,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (target != null)
{
UUID animID=UUID.Zero;
- lock (m_host.TaskInventory)
+ m_host.TaskInventory.LockItemsForRead(true);
+ foreach (KeyValuePair inv in m_host.TaskInventory)
{
- foreach (KeyValuePair inv in m_host.TaskInventory)
+ if (inv.Value.Name == animation)
{
- if (inv.Value.Name == animation)
- {
- if (inv.Value.Type == (int)AssetType.Animation)
- animID = inv.Value.AssetID;
- continue;
- }
+ if (inv.Value.Type == (int)AssetType.Animation)
+ animID = inv.Value.AssetID;
+ continue;
}
}
+ m_host.TaskInventory.LockItemsForRead(false);
if (animID == UUID.Zero)
target.Animator.RemoveAnimation(animation);
@@ -1541,6 +1539,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (!UUID.TryParse(name, out assetID))
{
+ m_host.TaskInventory.LockItemsForRead(true);
foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
{
if (item.Type == 7 && item.Name == name)
@@ -1548,6 +1547,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
assetID = item.AssetID;
}
}
+ m_host.TaskInventory.LockItemsForRead(false);
}
if (assetID == UUID.Zero)
@@ -1594,6 +1594,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (!UUID.TryParse(name, out assetID))
{
+ m_host.TaskInventory.LockItemsForRead(true);
foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
{
if (item.Type == 7 && item.Name == name)
@@ -1601,6 +1602,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
assetID = item.AssetID;
}
}
+ m_host.TaskInventory.LockItemsForRead(false);
}
if (assetID == UUID.Zero)
@@ -1651,6 +1653,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (!UUID.TryParse(name, out assetID))
{
+ m_host.TaskInventory.LockItemsForRead(true);
foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
{
if (item.Type == 7 && item.Name == name)
@@ -1658,6 +1661,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
assetID = item.AssetID;
}
}
+ m_host.TaskInventory.LockItemsForRead(false);
}
if (assetID == UUID.Zero)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
index 063d50f..0f4a9ad 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
@@ -238,13 +238,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
if (part != null)
{
- lock (part.TaskInventory)
+ part.TaskInventory.LockItemsForRead(true);
+ if (part.TaskInventory.ContainsKey(m_ItemID))
{
- if (part.TaskInventory.ContainsKey(m_ItemID))
- {
- m_thisScriptTask = part.TaskInventory[m_ItemID];
- }
+ m_thisScriptTask = part.TaskInventory[m_ItemID];
}
+ part.TaskInventory.LockItemsForRead(false);
}
ApiManager am = new ApiManager();
@@ -429,14 +428,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
{
int permsMask;
UUID permsGranter;
- lock (part.TaskInventory)
+ part.TaskInventory.LockItemsForRead(true);
+ if (!part.TaskInventory.ContainsKey(m_ItemID))
{
- if (!part.TaskInventory.ContainsKey(m_ItemID))
- return;
-
- permsGranter = part.TaskInventory[m_ItemID].PermsGranter;
- permsMask = part.TaskInventory[m_ItemID].PermsMask;
+ part.TaskInventory.LockItemsForRead(false);
+ return;
}
+ permsGranter = part.TaskInventory[m_ItemID].PermsGranter;
+ permsMask = part.TaskInventory[m_ItemID].PermsMask;
+ part.TaskInventory.LockItemsForRead(false);
if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0)
{
--
cgit v1.1
From c81f37cf82c3a9d2aae92d5f44734fc5098c5b75 Mon Sep 17 00:00:00 2001
From: Melanie
Date: Wed, 25 Nov 2009 17:01:41 +0000
Subject: Change osTeleportAgent parameters from long to int. That numerical
range is not even supported by the underlying type, so there is no need to
ask for a type the script can not even supply.
---
OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 4 ++--
OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 2 +-
OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 4 ++--
3 files changed, 5 insertions(+), 5 deletions(-)
(limited to 'OpenSim/Region/ScriptEngine')
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 83322eb..10165d3 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -636,13 +636,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
// Teleport functions
- public void osTeleportAgent(string agent, uint regionX, uint regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat)
+ public void osTeleportAgent(string agent, int regionX, int regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat)
{
// High because there is no security check. High griefer potential
//
CheckThreatLevel(ThreatLevel.High, "osTeleportAgent");
- ulong regionHandle = Util.UIntsToLong((regionX * (uint)Constants.RegionSize), (regionY * (uint)Constants.RegionSize));
+ ulong regionHandle = Util.UIntsToLong(((uint)regionX * (uint)Constants.RegionSize), ((uint)regionY * (uint)Constants.RegionSize));
m_host.AddScriptLPS(1);
UUID agentId = new UUID();
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
index 2a403bf..470946a 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
@@ -83,7 +83,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
// Teleport commands
void osTeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat);
- void osTeleportAgent(string agent, uint regionX, uint regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat);
+ void osTeleportAgent(string agent, int regionX, int regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat);
void osTeleportAgent(string agent, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat);
// Animation commands
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
index 4928e90..6b88834 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
@@ -201,9 +201,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
m_OSSL_Functions.osTeleportAgent(agent, regionName, position, lookat);
}
- public void osTeleportAgent(string agent, long regionX, long regionY, vector position, vector lookat)
+ public void osTeleportAgent(string agent, int regionX, int regionY, vector position, vector lookat)
{
- m_OSSL_Functions.osTeleportAgent(agent, (uint) regionX, (uint) regionY, position, lookat);
+ m_OSSL_Functions.osTeleportAgent(agent, regionX, regionY, position, lookat);
}
public void osTeleportAgent(string agent, vector position, vector lookat)
--
cgit v1.1
From 0b380f68d81267550b5adf45e16378e4648df933 Mon Sep 17 00:00:00 2001
From: Melanie
Date: Wed, 25 Nov 2009 17:01:41 +0000
Subject: Change osTeleportAgent parameters from long to int. That numerical
range is not even supported by the underlying type, so there is no need to
ask for a type the script can not even supply.
---
OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 4 ++--
OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 2 +-
OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 4 ++--
3 files changed, 5 insertions(+), 5 deletions(-)
(limited to 'OpenSim/Region/ScriptEngine')
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 7fdbac8..e72fa70 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -636,13 +636,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
// Teleport functions
- public void osTeleportAgent(string agent, uint regionX, uint regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat)
+ public void osTeleportAgent(string agent, int regionX, int regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat)
{
// High because there is no security check. High griefer potential
//
CheckThreatLevel(ThreatLevel.High, "osTeleportAgent");
- ulong regionHandle = Util.UIntsToLong((regionX * (uint)Constants.RegionSize), (regionY * (uint)Constants.RegionSize));
+ ulong regionHandle = Util.UIntsToLong(((uint)regionX * (uint)Constants.RegionSize), ((uint)regionY * (uint)Constants.RegionSize));
m_host.AddScriptLPS(1);
UUID agentId = new UUID();
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
index 2a403bf..470946a 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
@@ -83,7 +83,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
// Teleport commands
void osTeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat);
- void osTeleportAgent(string agent, uint regionX, uint regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat);
+ void osTeleportAgent(string agent, int regionX, int regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat);
void osTeleportAgent(string agent, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat);
// Animation commands
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
index 4928e90..6b88834 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
@@ -201,9 +201,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
m_OSSL_Functions.osTeleportAgent(agent, regionName, position, lookat);
}
- public void osTeleportAgent(string agent, long regionX, long regionY, vector position, vector lookat)
+ public void osTeleportAgent(string agent, int regionX, int regionY, vector position, vector lookat)
{
- m_OSSL_Functions.osTeleportAgent(agent, (uint) regionX, (uint) regionY, position, lookat);
+ m_OSSL_Functions.osTeleportAgent(agent, regionX, regionY, position, lookat);
}
public void osTeleportAgent(string agent, vector position, vector lookat)
--
cgit v1.1
From de927adf2709f50d0fe85a1c59e7677d862d0d72 Mon Sep 17 00:00:00 2001
From: Melanie
Date: Wed, 25 Nov 2009 20:01:21 +0000
Subject: Add the dummy "Size" property to the list type
---
OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs | 5 +++++
1 file changed, 5 insertions(+)
(limited to 'OpenSim/Region/ScriptEngine')
diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
index 3f38bb6..1fc31c5 100644
--- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
@@ -429,6 +429,11 @@ namespace OpenSim.Region.ScriptEngine.Shared
}
}
+ public int Size
+ {
+ get { return 0; }
+ }
+
public object[] Data
{
get {
--
cgit v1.1
From a5f2803c79b8d3a25124bef5f68afd57b5feba96 Mon Sep 17 00:00:00 2001
From: Teravus Ovares (Dan Olivares)
Date: Thu, 26 Nov 2009 01:34:46 -0500
Subject: * Re-enable the AbsolutePosition = AbsolutePosition in the LSL_Api in
the SetRot method if the object is not active physical. This is important
for scripted rotating doors. without AbsolutePosition = AbsolutePosition, the
door won't rotate. It's also important that we do not use AbsolutePosition
= AbsolutePosition if the object is active physical because that would cause
a complete rebuild of the object which would break vehicles. This is the
best of both worlds right now. Doors as child prim should work again so
long as you don't check the Physical box. * Thanks talentraspel * Thanks
NixNerd * Thanks KittoFlora * Thanks lockd
---
.../Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 12 ++++++++++++
1 file changed, 12 insertions(+)
(limited to 'OpenSim/Region/ScriptEngine')
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 9c62775..fbbbfdc 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -1987,6 +1987,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
//KF: Do NOT use this next line if using ODE physics engine. This need a switch based on .ini Phys Engine type
// part.ParentGroup.AbsolutePosition = part.ParentGroup.AbsolutePosition;
+
+ // So, after thinking about this for a bit, the issue with the part.ParentGroup.AbsolutePosition = part.ParentGroup.AbsolutePosition line
+ // is it isn't compatible with vehicles because it causes the vehicle body to have to be broken down and rebuilt
+ // It's perfectly okay when the object is not an active physical body though.
+ // So, part.ParentGroup.ResetChildPrimPhysicsPositions(); does the thing that Kitto is warning against
+ // but only if the object is not physial and active. This is important for rotating doors.
+ // without the absoluteposition = absoluteposition happening, the doors do not move in the physics
+ // scene
+ if (part.PhysActor != null && !part.PhysActor.IsPhysical)
+ {
+ part.ParentGroup.ResetChildPrimPhysicsPositions();
+ }
}
///
--
cgit v1.1
From 88842edc95bafeb9f3b2f2ea0ab09394028a0916 Mon Sep 17 00:00:00 2001
From: Melanie
Date: Thu, 26 Nov 2009 12:08:20 +0000
Subject: Remove GetAssemblyName and friends from the SE interface. It's now
handled internally
---
OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 95 +++++++++++++++++++++++---
1 file changed, 86 insertions(+), 9 deletions(-)
(limited to 'OpenSim/Region/ScriptEngine')
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index a60c0ba..0a9af2c 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -1245,20 +1245,97 @@ namespace OpenSim.Region.ScriptEngine.XEngine
}
}
- public string GetAssemblyName(UUID itemID)
- {
- IScriptInstance instance = GetInstance(itemID);
- if (instance == null)
- return "";
- return instance.GetAssemblyName();
- }
-
public string GetXMLState(UUID itemID)
{
IScriptInstance instance = GetInstance(itemID);
if (instance == null)
return "";
- return instance.GetXMLState();
+ string xml = instance.GetXMLState();
+
+ XmlDocument sdoc = new XmlDocument();
+ sdoc.LoadXml(xml);
+ XmlNodeList rootL = sdoc.GetElementsByTagName("ScriptState");
+ XmlNode rootNode = rootL[0];
+
+ // Create
+ XmlDocument doc = new XmlDocument();
+ XmlElement stateData = doc.CreateElement("", "State", "");
+ XmlAttribute stateID = doc.CreateAttribute("", "UUID", "");
+ stateID.Value = itemID.ToString();
+ stateData.Attributes.Append(stateID);
+ XmlAttribute assetID = doc.CreateAttribute("", "Asset", "");
+ assetID.Value = instance.AssetID.ToString();
+ stateData.Attributes.Append(assetID);
+ doc.AppendChild(stateData);
+
+ // Add ...
+ XmlNode xmlstate = doc.ImportNode(rootNode, true);
+ stateData.AppendChild(xmlstate);
+
+ string assemName = instance.GetAssemblyName();
+
+ string fn = Path.GetFileName(assemName);
+
+ string assem = String.Empty;
+
+ if (File.Exists(assemName + ".text"))
+ {
+ FileInfo tfi = new FileInfo(assemName + ".text");
+
+ if (tfi != null)
+ {
+ Byte[] tdata = new Byte[tfi.Length];
+
+ try
+ {
+ FileStream tfs = File.Open(assemName + ".text",
+ FileMode.Open, FileAccess.Read);
+ tfs.Read(tdata, 0, tdata.Length);
+ tfs.Close();
+
+ assem = new System.Text.ASCIIEncoding().GetString(tdata);
+ }
+ catch (Exception e)
+ {
+ m_log.DebugFormat("[XEngine]: Unable to open script textfile {0}, reason: {1}", assemName+".text", e.Message);
+ }
+ }
+ }
+ else
+ {
+ FileInfo fi = new FileInfo(assemName);
+
+ if (fi != null)
+ {
+ Byte[] data = new Byte[fi.Length];
+
+ try
+ {
+ FileStream fs = File.Open(assemName, FileMode.Open, FileAccess.Read);
+ fs.Read(data, 0, data.Length);
+ fs.Close();
+
+ assem = System.Convert.ToBase64String(data);
+ }
+ catch (Exception e)
+ {
+ m_log.DebugFormat("[XEngine]: Unable to open script assembly {0}, reason: {1}", assemName, e.Message);
+ }
+
+ }
+ }
+
+ XmlElement assemblyData = doc.CreateElement("", "Assembly", "");
+ XmlAttribute assemblyName = doc.CreateAttribute("", "Filename", "");
+
+ assemblyName.Value = fn;
+ assemblyData.Attributes.Append(assemblyName);
+
+ assemblyData.InnerText = assem;
+
+ stateData.AppendChild(assemblyData);
+
+ return doc.InnerXml;
}
public bool CanBeDeleted(UUID itemID)
--
cgit v1.1
From 22c325aa5ae06b897e5eb10404c0aa3727f8237b Mon Sep 17 00:00:00 2001
From: Melanie
Date: Thu, 26 Nov 2009 12:08:20 +0000
Subject: Remove GetAssemblyName and friends from the SE interface. It's now
handled internally
---
OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 95 +++++++++++++++++++++++---
1 file changed, 86 insertions(+), 9 deletions(-)
(limited to 'OpenSim/Region/ScriptEngine')
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index 8b94f28..4dc6cb8 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -1248,20 +1248,97 @@ namespace OpenSim.Region.ScriptEngine.XEngine
}
}
- public string GetAssemblyName(UUID itemID)
- {
- IScriptInstance instance = GetInstance(itemID);
- if (instance == null)
- return "";
- return instance.GetAssemblyName();
- }
-
public string GetXMLState(UUID itemID)
{
IScriptInstance instance = GetInstance(itemID);
if (instance == null)
return "";
- return instance.GetXMLState();
+ string xml = instance.GetXMLState();
+
+ XmlDocument sdoc = new XmlDocument();
+ sdoc.LoadXml(xml);
+ XmlNodeList rootL = sdoc.GetElementsByTagName("ScriptState");
+ XmlNode rootNode = rootL[0];
+
+ // Create
+ XmlDocument doc = new XmlDocument();
+ XmlElement stateData = doc.CreateElement("", "State", "");
+ XmlAttribute stateID = doc.CreateAttribute("", "UUID", "");
+ stateID.Value = itemID.ToString();
+ stateData.Attributes.Append(stateID);
+ XmlAttribute assetID = doc.CreateAttribute("", "Asset", "");
+ assetID.Value = instance.AssetID.ToString();
+ stateData.Attributes.Append(assetID);
+ doc.AppendChild(stateData);
+
+ // Add ...
+ XmlNode xmlstate = doc.ImportNode(rootNode, true);
+ stateData.AppendChild(xmlstate);
+
+ string assemName = instance.GetAssemblyName();
+
+ string fn = Path.GetFileName(assemName);
+
+ string assem = String.Empty;
+
+ if (File.Exists(assemName + ".text"))
+ {
+ FileInfo tfi = new FileInfo(assemName + ".text");
+
+ if (tfi != null)
+ {
+ Byte[] tdata = new Byte[tfi.Length];
+
+ try
+ {
+ FileStream tfs = File.Open(assemName + ".text",
+ FileMode.Open, FileAccess.Read);
+ tfs.Read(tdata, 0, tdata.Length);
+ tfs.Close();
+
+ assem = new System.Text.ASCIIEncoding().GetString(tdata);
+ }
+ catch (Exception e)
+ {
+ m_log.DebugFormat("[XEngine]: Unable to open script textfile {0}, reason: {1}", assemName+".text", e.Message);
+ }
+ }
+ }
+ else
+ {
+ FileInfo fi = new FileInfo(assemName);
+
+ if (fi != null)
+ {
+ Byte[] data = new Byte[fi.Length];
+
+ try
+ {
+ FileStream fs = File.Open(assemName, FileMode.Open, FileAccess.Read);
+ fs.Read(data, 0, data.Length);
+ fs.Close();
+
+ assem = System.Convert.ToBase64String(data);
+ }
+ catch (Exception e)
+ {
+ m_log.DebugFormat("[XEngine]: Unable to open script assembly {0}, reason: {1}", assemName, e.Message);
+ }
+
+ }
+ }
+
+ XmlElement assemblyData = doc.CreateElement("", "Assembly", "");
+ XmlAttribute assemblyName = doc.CreateAttribute("", "Filename", "");
+
+ assemblyName.Value = fn;
+ assemblyData.Attributes.Append(assemblyName);
+
+ assemblyData.InnerText = assem;
+
+ stateData.AppendChild(assemblyData);
+
+ return doc.InnerXml;
}
public bool CanBeDeleted(UUID itemID)
--
cgit v1.1
From 9d63f90467dbc60622a49f564a56fdd20de90f51 Mon Sep 17 00:00:00 2001
From: Melanie
Date: Thu, 26 Nov 2009 17:03:09 +0000
Subject: Remove the old (Remoting) region crossing code. Fix the new code to
pass script state and assembly again properly. Reintroduce respecting tht
TrustBinaries flag. Changes the interregion protocol! No version bump because
it was broken anyway, so with a version mismatch it will simply stay broken,
but not crash. Region corssing still doesn't work because there is still
monkey business with both rezzed prims being pushed across a border and
attached prims when walking across a border. Teleport is untested by may
work.
---
.../ScriptEngine/Interfaces/IScriptInstance.cs | 1 -
.../ScriptEngine/Shared/Instance/ScriptInstance.cs | 5 -
OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 124 +++++++++++++++++++--
3 files changed, 116 insertions(+), 14 deletions(-)
(limited to 'OpenSim/Region/ScriptEngine')
diff --git a/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs b/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs
index f49aea8..ae148a9 100644
--- a/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs
+++ b/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs
@@ -96,7 +96,6 @@ namespace OpenSim.Region.ScriptEngine.Interfaces
UUID GetDetectID(int idx);
void SaveState(string assembly);
void DestroyScriptInstance();
- bool CanBeDeleted();
IScriptApi GetApi(string name);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
index 41b5d49..5c5d57e 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
@@ -1011,10 +1011,5 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
{
get { return m_RegionID; }
}
-
- public bool CanBeDeleted()
- {
- return true;
- }
}
}
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index 0a9af2c..b099177 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -1325,6 +1325,19 @@ namespace OpenSim.Region.ScriptEngine.XEngine
}
}
+ string map = String.Empty;
+
+ if (File.Exists(fn + ".map"))
+ {
+ FileStream mfs = File.Open(fn + ".map", FileMode.Open, FileAccess.Read);
+ StreamReader msr = new StreamReader(mfs);
+
+ map = msr.ReadToEnd();
+
+ msr.Close();
+ mfs.Close();
+ }
+
XmlElement assemblyData = doc.CreateElement("", "Assembly", "");
XmlAttribute assemblyName = doc.CreateAttribute("", "Filename", "");
@@ -1335,21 +1348,116 @@ namespace OpenSim.Region.ScriptEngine.XEngine
stateData.AppendChild(assemblyData);
- return doc.InnerXml;
- }
+ XmlElement mapData = doc.CreateElement("", "LineMap", "");
+ XmlAttribute mapName = doc.CreateAttribute("", "Filename", "");
- public bool CanBeDeleted(UUID itemID)
- {
- IScriptInstance instance = GetInstance(itemID);
- if (instance == null)
- return true;
+ mapName.Value = fn + ".map";
+ mapData.Attributes.Append(mapName);
- return instance.CanBeDeleted();
+ mapData.InnerText = map;
+
+ stateData.AppendChild(mapData);
+ return doc.InnerXml;
}
private bool ShowScriptSaveResponse(UUID ownerID, UUID assetID, string text, bool compiled)
{
return false;
}
+
+ public void SetXMLState(UUID itemID, string xml)
+ {
+ if (xml == String.Empty)
+ return;
+
+ XmlDocument doc = new XmlDocument();
+
+ try
+ {
+ doc.LoadXml(xml);
+ }
+ catch (Exception)
+ {
+ m_log.Error("[XEngine]: Exception decoding XML data from region transfer");
+ return;
+ }
+
+ XmlNodeList rootL = doc.GetElementsByTagName("State");
+ if (rootL.Count < 1)
+ return;
+
+ XmlElement rootE = (XmlElement)rootL[0];
+
+ if (rootE.GetAttribute("UUID") != itemID.ToString())
+ return;
+
+ string assetID = rootE.GetAttribute("Asset");
+
+ XmlNodeList stateL = rootE.GetElementsByTagName("ScriptState");
+
+ if (stateL.Count != 1)
+ return;
+
+ XmlElement stateE = (XmlElement)stateL[0];
+
+ if (World.m_trustBinaries)
+ {
+ XmlNodeList assemL = rootE.GetElementsByTagName("Assembly");
+
+ if (assemL.Count != 1)
+ return;
+
+ XmlElement assemE = (XmlElement)assemL[0];
+
+ string fn = assemE.GetAttribute("Filename");
+ string base64 = assemE.InnerText;
+
+ string path = Path.Combine("ScriptEngines", World.RegionInfo.RegionID.ToString());
+ path = Path.Combine(path, fn);
+
+ if (!File.Exists(path))
+ {
+ Byte[] filedata = Convert.FromBase64String(base64);
+
+ FileStream fs = File.Create(path);
+ fs.Write(filedata, 0, filedata.Length);
+ fs.Close();
+
+ fs = File.Create(path + ".text");
+ StreamWriter sw = new StreamWriter(fs);
+
+ sw.Write(base64);
+
+ sw.Close();
+ fs.Close();
+ }
+ }
+
+ string statepath = Path.Combine("ScriptEngines", World.RegionInfo.RegionID.ToString());
+ statepath = Path.Combine(statepath, itemID.ToString() + ".state");
+
+ FileStream sfs = File.Create(statepath);
+ StreamWriter ssw = new StreamWriter(sfs);
+
+ ssw.Write(stateE.OuterXml);
+
+ ssw.Close();
+ sfs.Close();
+
+ XmlNodeList mapL = rootE.GetElementsByTagName("LineMap");
+
+ XmlElement mapE = (XmlElement)mapL[0];
+
+ string mappath = Path.Combine("ScriptEngines", World.RegionInfo.RegionID.ToString());
+ mappath = Path.Combine(mappath, mapE.GetAttribute("Filename"));
+
+ FileStream mfs = File.Create(mappath);
+ StreamWriter msw = new StreamWriter(sfs);
+
+ msw.Write(mapE.InnerText);
+
+ msw.Close();
+ mfs.Close();
+ }
}
}
--
cgit v1.1
From c6bfecccaa3b1128c6d670bdedc13275732e738b Mon Sep 17 00:00:00 2001
From: Melanie
Date: Thu, 26 Nov 2009 17:16:02 +0000
Subject: Fix a small bug. Trusted script crossings now work again
---
OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'OpenSim/Region/ScriptEngine')
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index b099177..5584f87 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -1452,7 +1452,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
mappath = Path.Combine(mappath, mapE.GetAttribute("Filename"));
FileStream mfs = File.Create(mappath);
- StreamWriter msw = new StreamWriter(sfs);
+ StreamWriter msw = new StreamWriter(mfs);
msw.Write(mapE.InnerText);
--
cgit v1.1
From d39c300d11109553b75ca761d26dda278c0ad7dd Mon Sep 17 00:00:00 2001
From: Jeff Lee
Date: Sun, 22 Nov 2009 18:10:46 -0500
Subject: Added osGetRegionStats() function, to return a number of sim
statistics
---
.../Shared/Api/Implementation/LSL_Api.cs | 1 +
.../Shared/Api/Implementation/OSSL_Api.cs | 15 ++++++++++++++
.../ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 1 +
.../Shared/Api/Runtime/LSL_Constants.cs | 23 ++++++++++++++++++++++
.../ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 5 +++++
5 files changed, 45 insertions(+)
(limited to 'OpenSim/Region/ScriptEngine')
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index fbbbfdc..5de23ad 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -5784,6 +5784,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_host.AddScriptLPS(1);
return World.SimulatorFPS;
}
+
/* particle system rules should be coming into this routine as doubles, that is
rule[0] should be an integer from this list and rule[1] should be the arg
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index e72fa70..482bfbc 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -1948,5 +1948,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return key.ToString();
}
+
+ public LSL_List osGetRegionStats()
+ {
+ CheckThreatLevel(ThreatLevel.High, "osGetRegionStats");
+ m_host.AddScriptLPS(1);
+ LSL_List ret = new LSL_List();
+ float[] stats = World.SimulatorStats;
+
+ for (int i = 0; i < 21; i++)
+ {
+ ret.Add(new LSL_Float( stats[i] ));
+ }
+ return ret;
+ }
+
}
}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
index 470946a..0b0dc00 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
@@ -162,5 +162,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
key osGetMapTexture();
key osGetRegionMapTexture(string regionName);
+ LSL_List osGetRegionStats();
}
}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
index 753ca55..acff8fb 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
@@ -515,6 +515,29 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
public const string TEXTURE_PLYWOOD = "89556747-24cb-43ed-920b-47caed15465f";
public const string TEXTURE_TRANSPARENT = "8dcd4a48-2d37-4909-9f78-f7a9eb4ef903";
public const string TEXTURE_MEDIA = "8b5fec65-8d8d-9dc5-cda8-8fdf2716e361";
+
+ // Constants for osGetRegionStats
+ public const int STATS_TIME_DILATION = 0;
+ public const int STATS_SIM_FPS = 1;
+ public const int STATS_PHYSICS_FPS = 2;
+ public const int STATS_AGENT_UPDATES = 3;
+ public const int STATS_ROOT_AGENTS = 4;
+ public const int STATS_CHILD_AGENTS = 5;
+ public const int STATS_TOTAL_PRIMS = 6;
+ public const int STATS_ACTIVE_PRIMS = 7;
+ public const int STATS_FRAME_MS = 8;
+ public const int STATS_NET_MS = 9;
+ public const int STATS_PHYSICS_MS = 10;
+ public const int STATS_IMAGE_MS = 11;
+ public const int STATS_OTHER_MS = 12;
+ public const int STATS_IN_PACKETS_PER_SECOND = 13;
+ public const int STATS_OUT_PACKETS_PER_SECOND = 14;
+ public const int STATS_UNACKED_BYTES = 15;
+ public const int STATS_AGENT_MS = 16;
+ public const int STATS_PENDING_DOWNLOADS = 17;
+ public const int STATS_PENDING_UPLOADS = 18;
+ public const int STATS_ACTIVE_SCRIPTS = 19;
+ public const int STATS_SCRIPT_LPS = 20;
}
}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
index 6b88834..519463e 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
@@ -632,5 +632,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
{
return m_OSSL_Functions.osGetRegionMapTexture(regionName);
}
+
+ public LSL_List osGetRegionStats()
+ {
+ return m_OSSL_Functions.osGetRegionStats();
+ }
}
}
--
cgit v1.1
From 9d05962029fe864408d287d5fa7ef81f312e098a Mon Sep 17 00:00:00 2001
From: Jeff Lee
Date: Mon, 23 Nov 2009 11:53:37 -0500
Subject: Added osGetRegionStats() function, to return a number of sim
statistics
---
.../Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
(limited to 'OpenSim/Region/ScriptEngine')
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 482bfbc..5501679 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -1949,9 +1949,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return key.ToString();
}
+ ///
+ /// Return information regarding various simulator statistics (sim fps, physics fps, time
+ /// dilation, total number of prims, total number of active scripts, script lps, various
+ /// timing data, packets in/out, etc. Basically much the information that's shown in the
+ /// client's Statistics Bar (Ctrl-Shift-1)
+ ///
+ /// List of floats
public LSL_List osGetRegionStats()
{
- CheckThreatLevel(ThreatLevel.High, "osGetRegionStats");
+ CheckThreatLevel(ThreatLevel.Moderate, "osGetRegionStats");
m_host.AddScriptLPS(1);
LSL_List ret = new LSL_List();
float[] stats = World.SimulatorStats;
--
cgit v1.1