aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs9
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs14
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs13
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptSponsor.cs17
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs11
5 files changed, 48 insertions, 16 deletions
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs
index bd60759..b5cbd25 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs
@@ -28,6 +28,8 @@
28using System; 28using System;
29using System.Reflection; 29using System.Reflection;
30using System.Globalization; 30using System.Globalization;
31using System.Runtime.Remoting;
32using System.Runtime.Remoting.Lifetime;
31using log4net; 33using log4net;
32using OpenMetaverse; 34using OpenMetaverse;
33using OpenSim.Framework; 35using OpenSim.Framework;
@@ -39,6 +41,7 @@ using System.Collections.Generic;
39using System.IO; 41using System.IO;
40using System.Runtime.Serialization.Formatters.Binary; 42using System.Runtime.Serialization.Formatters.Binary;
41using System.Threading; 43using System.Threading;
44using OpenSim.Region.ScriptEngine.Shared.Api.Runtime;
42using OpenSim.Region.ScriptEngine.Shared.ScriptBase; 45using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
43using OpenSim.Region.ScriptEngine.Shared.CodeTools; 46using OpenSim.Region.ScriptEngine.Shared.CodeTools;
44 47
@@ -56,6 +59,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
56 public Dictionary<string, IScriptApi> Apis; 59 public Dictionary<string, IScriptApi> Apis;
57 public Dictionary<KeyValuePair<int,int>, KeyValuePair<int,int>> 60 public Dictionary<KeyValuePair<int,int>, KeyValuePair<int,int>>
58 LineMap; 61 LineMap;
62 public ISponsor ScriptSponsor;
59 } 63 }
60 64
61 public class ScriptManager 65 public class ScriptManager
@@ -164,6 +168,11 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
164 CompiledScript = 168 CompiledScript =
165 m_scriptEngine.m_AppDomainManager.LoadScript( 169 m_scriptEngine.m_AppDomainManager.LoadScript(
166 CompiledScriptFile, out id.AppDomain); 170 CompiledScriptFile, out id.AppDomain);
171 //Register the sponsor
172 ISponsor scriptSponsor = new ScriptSponsor();
173 ILease lease = (ILease)RemotingServices.GetLifetimeService(CompiledScript as MarshalByRefObject);
174 lease.Register(scriptSponsor);
175 id.ScriptSponsor = scriptSponsor;
167 176
168 id.LineMap = LSLCompiler.LineMap(); 177 id.LineMap = LSLCompiler.LineMap();
169 id.Script = CompiledScript; 178 id.Script = CompiledScript;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 17dca98..cbd99bb 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -29,6 +29,7 @@ using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Runtime.Remoting.Lifetime; 31using System.Runtime.Remoting.Lifetime;
32using System.Security.Permissions;
32using System.Text; 33using System.Text;
33using System.Threading; 34using System.Threading;
34using Nini.Config; 35using Nini.Config;
@@ -64,7 +65,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
64 /// <summary> 65 /// <summary>
65 /// Contains all LSL ll-functions. This class will be in Default AppDomain. 66 /// Contains all LSL ll-functions. This class will be in Default AppDomain.
66 /// </summary> 67 /// </summary>
67 public class LSL_Api : MarshalByRefObject, ILSL_Api, IScriptApi 68 public class LSL_Api : ILSL_Api, IScriptApi
68 { 69 {
69 protected IScriptEngine m_ScriptEngine; 70 protected IScriptEngine m_ScriptEngine;
70 protected SceneObjectPart m_host; 71 protected SceneObjectPart m_host;
@@ -98,17 +99,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
98 AsyncCommands = new AsyncCommandManager(ScriptEngine); 99 AsyncCommands = new AsyncCommandManager(ScriptEngine);
99 } 100 }
100 101
101 // Object never expires
102 public override Object InitializeLifetimeService()
103 {
104 ILease lease = (ILease)base.InitializeLifetimeService();
105 102
106 if (lease.CurrentState == LeaseState.Initial) 103
107 {
108 lease.InitialLeaseTime = TimeSpan.Zero;
109 }
110 return lease;
111 }
112 104
113 protected void ScriptSleep(int delay) 105 protected void ScriptSleep(int delay)
114 { 106 {
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs
index 25c823d..06307bb 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs
@@ -27,6 +27,7 @@
27 27
28using System; 28using System;
29using System.Runtime.Remoting.Lifetime; 29using System.Runtime.Remoting.Lifetime;
30using System.Security.Permissions;
30using System.Threading; 31using System.Threading;
31using System.Reflection; 32using System.Reflection;
32using System.Collections; 33using System.Collections;
@@ -40,16 +41,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
40 { 41 {
41 private Dictionary<string,MethodInfo> inits = new Dictionary<string,MethodInfo>(); 42 private Dictionary<string,MethodInfo> inits = new Dictionary<string,MethodInfo>();
42 43
43 // 44 // Object expires if we don't keep it alive
44 // Never expire this object 45 // sponsor will be added on object load
45 // 46 [SecurityPermissionAttribute(SecurityAction.Demand,
47 Flags = SecurityPermissionFlag.Infrastructure)]
46 public override Object InitializeLifetimeService() 48 public override Object InitializeLifetimeService()
47 { 49 {
48 ILease lease = (ILease)base.InitializeLifetimeService(); 50 ILease lease = (ILease)base.InitializeLifetimeService();
49
50 if (lease.CurrentState == LeaseState.Initial) 51 if (lease.CurrentState == LeaseState.Initial)
51 { 52 {
52 lease.InitialLeaseTime = TimeSpan.Zero; 53 lease.InitialLeaseTime = TimeSpan.FromMinutes(1);
54 lease.SponsorshipTimeout = TimeSpan.FromMinutes(2);
55 lease.RenewOnCallTime = TimeSpan.FromSeconds(2);
53 } 56 }
54 return lease; 57 return lease;
55 } 58 }
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptSponsor.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptSponsor.cs
new file mode 100644
index 0000000..87401bb
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptSponsor.cs
@@ -0,0 +1,17 @@
1using System;
2using System.Collections.Generic;
3using System.Runtime.Remoting.Lifetime;
4using System.Text;
5
6namespace OpenSim.Region.ScriptEngine.Shared.Api.Runtime
7{
8 public class ScriptSponsor: ISponsor
9 {
10 // In theory: I execute, therefore I am.
11 // If GC collects this class then sponsorship will expire
12 public TimeSpan Renewal(ILease lease)
13 {
14 return TimeSpan.FromMinutes(2);
15 }
16 }
17}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
index ad86494..2a8bba8 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
@@ -27,6 +27,8 @@
27 27
28using System; 28using System;
29using System.IO; 29using System.IO;
30using System.Runtime.Remoting;
31using System.Runtime.Remoting.Lifetime;
30using System.Threading; 32using System.Threading;
31using System.Collections; 33using System.Collections;
32using System.Collections.Generic; 34using System.Collections.Generic;
@@ -44,6 +46,7 @@ using OpenSim.Region.Environment.Scenes;
44using OpenSim.Region.Environment.Interfaces; 46using OpenSim.Region.Environment.Interfaces;
45using OpenSim.Region.ScriptEngine.Shared; 47using OpenSim.Region.ScriptEngine.Shared;
46using OpenSim.Region.ScriptEngine.Shared.Api; 48using OpenSim.Region.ScriptEngine.Shared.Api;
49using OpenSim.Region.ScriptEngine.Shared.Api.Runtime;
47using OpenSim.Region.ScriptEngine.Shared.ScriptBase; 50using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
48using OpenSim.Region.ScriptEngine.Shared.CodeTools; 51using OpenSim.Region.ScriptEngine.Shared.CodeTools;
49using OpenSim.Region.ScriptEngine.Interfaces; 52using OpenSim.Region.ScriptEngine.Interfaces;
@@ -80,6 +83,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
80 private int m_ControlEventsInQueue = 0; 83 private int m_ControlEventsInQueue = 0;
81 private int m_LastControlLevel = 0; 84 private int m_LastControlLevel = 0;
82 private bool m_CollisionInQueue = false; 85 private bool m_CollisionInQueue = false;
86 private ISponsor m_ScriptSponsor;
83 private Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> 87 private Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>>
84 m_LineMap; 88 m_LineMap;
85 89
@@ -204,6 +208,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
204 m_Script = (IScript)dom.CreateInstanceAndUnwrap( 208 m_Script = (IScript)dom.CreateInstanceAndUnwrap(
205 Path.GetFileNameWithoutExtension(assembly), 209 Path.GetFileNameWithoutExtension(assembly),
206 "SecondLife.Script"); 210 "SecondLife.Script");
211
212 // Add a sponsor to the script
213 ISponsor scriptSponsor = new ScriptSponsor();
214 ILease lease = (ILease)RemotingServices.GetLifetimeService(m_Script as MarshalByRefObject);
215 lease.Register(scriptSponsor);
216 m_ScriptSponsor = scriptSponsor;
217
207 } 218 }
208 catch (Exception e) 219 catch (Exception e)
209 { 220 {