diff options
author | Tedd Hansen | 2008-11-26 11:12:57 +0000 |
---|---|---|
committer | Tedd Hansen | 2008-11-26 11:12:57 +0000 |
commit | e6ddb5de7de4ed61fa19b3805cd77104328eb20a (patch) | |
tree | 37c975b8d660174d96c05830daf7aab92eaf2309 /OpenSim/Region/ScriptEngine/Shared/Api | |
parent | Comment one more field that can't be tested that way anymore (diff) | |
download | opensim-SC_OLD-e6ddb5de7de4ed61fa19b3805cd77104328eb20a.zip opensim-SC_OLD-e6ddb5de7de4ed61fa19b3805cd77104328eb20a.tar.gz opensim-SC_OLD-e6ddb5de7de4ed61fa19b3805cd77104328eb20a.tar.bz2 opensim-SC_OLD-e6ddb5de7de4ed61fa19b3805cd77104328eb20a.tar.xz |
Attempt to give script objects a proper lease time (DNE and xengine). Relies on GC. Also removed lease for LSL_Api as it strictly speaking should not be MarshalByRef. Or should it? If so I broke scripting! :)
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api')
3 files changed, 28 insertions, 16 deletions
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; | |||
29 | using System.Collections; | 29 | using System.Collections; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Runtime.Remoting.Lifetime; | 31 | using System.Runtime.Remoting.Lifetime; |
32 | using System.Security.Permissions; | ||
32 | using System.Text; | 33 | using System.Text; |
33 | using System.Threading; | 34 | using System.Threading; |
34 | using Nini.Config; | 35 | using 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 | ||
28 | using System; | 28 | using System; |
29 | using System.Runtime.Remoting.Lifetime; | 29 | using System.Runtime.Remoting.Lifetime; |
30 | using System.Security.Permissions; | ||
30 | using System.Threading; | 31 | using System.Threading; |
31 | using System.Reflection; | 32 | using System.Reflection; |
32 | using System.Collections; | 33 | using 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 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Runtime.Remoting.Lifetime; | ||
4 | using System.Text; | ||
5 | |||
6 | namespace 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 | } | ||