diff options
author | Melanie | 2013-01-24 00:25:08 +0000 |
---|---|---|
committer | Melanie | 2013-01-24 00:25:08 +0000 |
commit | be4c8c4931637b7b0849d12c634599c702483364 (patch) | |
tree | 9a49626efcc10f1272b37176616a41476b044045 /OpenSim/Region/ScriptEngine/XEngine | |
parent | Merge branch 'master' into careminster (diff) | |
parent | Merge branch 'master' into cooptermination (diff) | |
download | opensim-SC_OLD-be4c8c4931637b7b0849d12c634599c702483364.zip opensim-SC_OLD-be4c8c4931637b7b0849d12c634599c702483364.tar.gz opensim-SC_OLD-be4c8c4931637b7b0849d12c634599c702483364.tar.bz2 opensim-SC_OLD-be4c8c4931637b7b0849d12c634599c702483364.tar.xz |
Merge branch 'master' into careminster
Conflicts:
OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
Diffstat (limited to 'OpenSim/Region/ScriptEngine/XEngine')
-rw-r--r-- | OpenSim/Region/ScriptEngine/XEngine/Api/Runtime/XEngineScriptBase.cs | 61 | ||||
-rw-r--r-- | OpenSim/Region/ScriptEngine/XEngine/EventManager.cs | 4 | ||||
-rw-r--r-- | OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineBasicTests.cs (renamed from OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineTest.cs) | 0 | ||||
-rw-r--r-- | OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 54 |
4 files changed, 101 insertions, 18 deletions
diff --git a/OpenSim/Region/ScriptEngine/XEngine/Api/Runtime/XEngineScriptBase.cs b/OpenSim/Region/ScriptEngine/XEngine/Api/Runtime/XEngineScriptBase.cs new file mode 100644 index 0000000..f4211c8 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/XEngine/Api/Runtime/XEngineScriptBase.cs | |||
@@ -0,0 +1,61 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Runtime.Remoting; | ||
30 | using System.Runtime.Remoting.Lifetime; | ||
31 | using System.Security.Permissions; | ||
32 | using System.Threading; | ||
33 | using System.Reflection; | ||
34 | using System.Collections; | ||
35 | using System.Collections.Generic; | ||
36 | using OpenSim.Region.ScriptEngine.Interfaces; | ||
37 | using OpenSim.Region.ScriptEngine.Shared; | ||
38 | using OpenSim.Region.ScriptEngine.Shared.ScriptBase; | ||
39 | |||
40 | namespace OpenSim.Region.ScriptEngine.XEngine.ScriptBase | ||
41 | { | ||
42 | public class XEngineScriptBase : ScriptBaseClass | ||
43 | { | ||
44 | /// <summary> | ||
45 | /// Used for script sleeps when we are using co-operative script termination. | ||
46 | /// </summary> | ||
47 | /// <remarks>null if co-operative script termination is not active</remarks> | ||
48 | WaitHandle m_coopSleepHandle; | ||
49 | |||
50 | public XEngineScriptBase(WaitHandle coopSleepHandle) : base() | ||
51 | { | ||
52 | m_coopSleepHandle = coopSleepHandle; | ||
53 | } | ||
54 | |||
55 | public void opensim_reserved_CheckForCoopTermination() | ||
56 | { | ||
57 | if (m_coopSleepHandle != null && m_coopSleepHandle.WaitOne(0)) | ||
58 | throw new ScriptCoopStopException(); | ||
59 | } | ||
60 | } | ||
61 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs b/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs index 9405075..afde685 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs | |||
@@ -52,7 +52,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
52 | { | 52 | { |
53 | myScriptEngine = _ScriptEngine; | 53 | myScriptEngine = _ScriptEngine; |
54 | 54 | ||
55 | m_log.Info("[XEngine] Hooking up to server events"); | 55 | // m_log.Info("[XEngine] Hooking up to server events"); |
56 | myScriptEngine.World.EventManager.OnAttach += attach; | 56 | myScriptEngine.World.EventManager.OnAttach += attach; |
57 | myScriptEngine.World.EventManager.OnObjectGrab += touch_start; | 57 | myScriptEngine.World.EventManager.OnObjectGrab += touch_start; |
58 | myScriptEngine.World.EventManager.OnObjectGrabbing += touch; | 58 | myScriptEngine.World.EventManager.OnObjectGrabbing += touch; |
@@ -69,7 +69,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
69 | myScriptEngine.World.EventManager.OnScriptLandColliderStart += land_collision_start; | 69 | myScriptEngine.World.EventManager.OnScriptLandColliderStart += land_collision_start; |
70 | myScriptEngine.World.EventManager.OnScriptLandColliding += land_collision; | 70 | myScriptEngine.World.EventManager.OnScriptLandColliding += land_collision; |
71 | myScriptEngine.World.EventManager.OnScriptLandColliderEnd += land_collision_end; | 71 | myScriptEngine.World.EventManager.OnScriptLandColliderEnd += land_collision_end; |
72 | IMoneyModule money=myScriptEngine.World.RequestModuleInterface<IMoneyModule>(); | 72 | IMoneyModule money = myScriptEngine.World.RequestModuleInterface<IMoneyModule>(); |
73 | if (money != null) | 73 | if (money != null) |
74 | { | 74 | { |
75 | money.OnObjectPaid+=HandleObjectPaid; | 75 | money.OnObjectPaid+=HandleObjectPaid; |
diff --git a/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineTest.cs b/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineBasicTests.cs index 5abfe9a..5abfe9a 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineTest.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineBasicTests.cs | |||
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 816d8ba..6e04e79 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | |||
@@ -47,13 +47,15 @@ using OpenSim.Framework; | |||
47 | using OpenSim.Framework.Console; | 47 | using OpenSim.Framework.Console; |
48 | using OpenSim.Region.Framework.Scenes; | 48 | using OpenSim.Region.Framework.Scenes; |
49 | using OpenSim.Region.Framework.Interfaces; | 49 | using OpenSim.Region.Framework.Interfaces; |
50 | using OpenSim.Region.ScriptEngine.Interfaces; | ||
50 | using OpenSim.Region.ScriptEngine.Shared; | 51 | using OpenSim.Region.ScriptEngine.Shared; |
51 | using OpenSim.Region.ScriptEngine.Shared.ScriptBase; | 52 | using OpenSim.Region.ScriptEngine.Shared.ScriptBase; |
52 | using OpenSim.Region.ScriptEngine.Shared.CodeTools; | 53 | using OpenSim.Region.ScriptEngine.Shared.CodeTools; |
53 | using OpenSim.Region.ScriptEngine.Shared.Instance; | 54 | using OpenSim.Region.ScriptEngine.Shared.Instance; |
54 | using OpenSim.Region.ScriptEngine.Shared.Api; | 55 | using OpenSim.Region.ScriptEngine.Shared.Api; |
55 | using OpenSim.Region.ScriptEngine.Shared.Api.Plugins; | 56 | using OpenSim.Region.ScriptEngine.Shared.Api.Plugins; |
56 | using OpenSim.Region.ScriptEngine.Interfaces; | 57 | using OpenSim.Region.ScriptEngine.Shared.ScriptBase; |
58 | using OpenSim.Region.ScriptEngine.XEngine.ScriptBase; | ||
57 | using Timer = OpenSim.Region.ScriptEngine.Shared.Api.Plugins.Timer; | 59 | using Timer = OpenSim.Region.ScriptEngine.Shared.Api.Plugins.Timer; |
58 | 60 | ||
59 | using ScriptCompileQueue = OpenSim.Framework.LocklessQueue<object[]>; | 61 | using ScriptCompileQueue = OpenSim.Framework.LocklessQueue<object[]>; |
@@ -244,6 +246,14 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
244 | get { return "XEngine"; } | 246 | get { return "XEngine"; } |
245 | } | 247 | } |
246 | 248 | ||
249 | public string ScriptClassName { get; private set; } | ||
250 | |||
251 | public string ScriptBaseClassName { get; private set; } | ||
252 | |||
253 | public ParameterInfo[] ScriptBaseClassParameters { get; private set; } | ||
254 | |||
255 | public string[] ScriptReferencedAssemblies { get; private set; } | ||
256 | |||
247 | public Scene World | 257 | public Scene World |
248 | { | 258 | { |
249 | get { return m_Scene; } | 259 | get { return m_Scene; } |
@@ -298,21 +308,35 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
298 | 308 | ||
299 | m_ScriptConfig = configSource.Configs["XEngine"]; | 309 | m_ScriptConfig = configSource.Configs["XEngine"]; |
300 | m_ConfigSource = configSource; | 310 | m_ConfigSource = configSource; |
311 | |||
312 | string rawScriptStopStrategy = m_ScriptConfig.GetString("ScriptStopStrategy", "abort"); | ||
313 | |||
314 | m_log.InfoFormat("[XEngine]: Script stop strategy is {0}", rawScriptStopStrategy); | ||
315 | |||
316 | if (rawScriptStopStrategy == "co-op") | ||
317 | { | ||
318 | ScriptClassName = "XEngineScript"; | ||
319 | ScriptBaseClassName = typeof(XEngineScriptBase).FullName; | ||
320 | ScriptBaseClassParameters = typeof(XEngineScriptBase).GetConstructor(new Type[] { typeof(WaitHandle) }).GetParameters(); | ||
321 | ScriptReferencedAssemblies = new string[] { Path.GetFileName(typeof(XEngineScriptBase).Assembly.Location) }; | ||
322 | } | ||
323 | else | ||
324 | { | ||
325 | ScriptClassName = "Script"; | ||
326 | ScriptBaseClassName = typeof(ScriptBaseClass).FullName; | ||
327 | } | ||
328 | |||
329 | // Console.WriteLine("ASSEMBLY NAME: {0}", ScriptReferencedAssemblies[0]); | ||
301 | } | 330 | } |
302 | 331 | ||
303 | public void AddRegion(Scene scene) | 332 | public void AddRegion(Scene scene) |
304 | { | 333 | { |
305 | if (m_ScriptConfig == null) | 334 | if (m_ScriptConfig == null) |
306 | return; | 335 | return; |
336 | |||
307 | m_ScriptFailCount = 0; | 337 | m_ScriptFailCount = 0; |
308 | m_ScriptErrorMessage = String.Empty; | 338 | m_ScriptErrorMessage = String.Empty; |
309 | 339 | ||
310 | if (m_ScriptConfig == null) | ||
311 | { | ||
312 | // m_log.ErrorFormat("[XEngine] No script configuration found. Scripts disabled"); | ||
313 | return; | ||
314 | } | ||
315 | |||
316 | m_Enabled = m_ScriptConfig.GetBoolean("Enabled", true); | 340 | m_Enabled = m_ScriptConfig.GetBoolean("Enabled", true); |
317 | 341 | ||
318 | if (!m_Enabled) | 342 | if (!m_Enabled) |
@@ -1180,7 +1204,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1180 | } | 1204 | } |
1181 | 1205 | ||
1182 | m_log.DebugFormat( | 1206 | m_log.DebugFormat( |
1183 | "[XEngine] Loading script {0}.{1}, item UUID {2}, prim UUID {3} @ {4}.{5}", | 1207 | "[XEngine]: Loading script {0}.{1}, item UUID {2}, prim UUID {3} @ {4}.{5}", |
1184 | part.ParentGroup.RootPart.Name, item.Name, itemID, part.UUID, | 1208 | part.ParentGroup.RootPart.Name, item.Name, itemID, part.UUID, |
1185 | part.ParentGroup.RootPart.AbsolutePosition, part.ParentGroup.Scene.RegionInfo.RegionName); | 1209 | part.ParentGroup.RootPart.AbsolutePosition, part.ParentGroup.Scene.RegionInfo.RegionName); |
1186 | 1210 | ||
@@ -1201,6 +1225,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1201 | lock (m_AddingAssemblies) | 1225 | lock (m_AddingAssemblies) |
1202 | { | 1226 | { |
1203 | m_Compiler.PerformScriptCompile(script, assetID.ToString(), item.OwnerID, out assembly, out linemap); | 1227 | m_Compiler.PerformScriptCompile(script, assetID.ToString(), item.OwnerID, out assembly, out linemap); |
1228 | |||
1204 | if (!m_AddingAssemblies.ContainsKey(assembly)) { | 1229 | if (!m_AddingAssemblies.ContainsKey(assembly)) { |
1205 | m_AddingAssemblies[assembly] = 1; | 1230 | m_AddingAssemblies[assembly] = 1; |
1206 | } else { | 1231 | } else { |
@@ -1250,7 +1275,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1250 | } | 1275 | } |
1251 | catch (Exception e) | 1276 | catch (Exception e) |
1252 | { | 1277 | { |
1253 | // m_log.ErrorFormat("[XEngine]: Exception when rezzing script {0}{1}", e.Message, e.StackTrace); | 1278 | // m_log.ErrorFormat( |
1279 | // "[XEngine]: Exception when rezzing script with item ID {0}, {1}{2}", | ||
1280 | // itemID, e.Message, e.StackTrace); | ||
1254 | 1281 | ||
1255 | // try | 1282 | // try |
1256 | // { | 1283 | // { |
@@ -1329,13 +1356,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1329 | sandbox = AppDomain.CurrentDomain; | 1356 | sandbox = AppDomain.CurrentDomain; |
1330 | } | 1357 | } |
1331 | 1358 | ||
1332 | //PolicyLevel sandboxPolicy = PolicyLevel.CreateAppDomainLevel(); | 1359 | if (!instance.Load(m_AppDomains[appDomain], assembly, stateSource)) |
1333 | //AllMembershipCondition sandboxMembershipCondition = new AllMembershipCondition(); | 1360 | return false; |
1334 | //PermissionSet sandboxPermissionSet = sandboxPolicy.GetNamedPermissionSet("Internet"); | ||
1335 | //PolicyStatement sandboxPolicyStatement = new PolicyStatement(sandboxPermissionSet); | ||
1336 | //CodeGroup sandboxCodeGroup = new UnionCodeGroup(sandboxMembershipCondition, sandboxPolicyStatement); | ||
1337 | //sandboxPolicy.RootCodeGroup = sandboxCodeGroup; | ||
1338 | //sandbox.SetAppDomainPolicy(sandboxPolicy); | ||
1339 | 1361 | ||
1340 | m_AppDomains[appDomain] = sandbox; | 1362 | m_AppDomains[appDomain] = sandbox; |
1341 | 1363 | ||