diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api')
6 files changed, 32 insertions, 41 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index bc36fda..5f9b09b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -119,14 +119,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
119 | AsyncCommands = new AsyncCommandManager(ScriptEngine); | 119 | AsyncCommands = new AsyncCommandManager(ScriptEngine); |
120 | } | 120 | } |
121 | 121 | ||
122 | // Object never expires | ||
123 | public override Object InitializeLifetimeService() | 122 | public override Object InitializeLifetimeService() |
124 | { | 123 | { |
125 | ILease lease = (ILease)base.InitializeLifetimeService(); | 124 | ILease lease = (ILease)base.InitializeLifetimeService(); |
126 | 125 | ||
127 | if (lease.CurrentState == LeaseState.Initial) | 126 | if (lease.CurrentState == LeaseState.Initial) |
128 | { | 127 | { |
129 | lease.InitialLeaseTime = TimeSpan.Zero; | 128 | lease.InitialLeaseTime = TimeSpan.FromMinutes(1.0); |
129 | lease.RenewOnCallTime = TimeSpan.FromSeconds(10.0); | ||
130 | lease.SponsorshipTimeout = TimeSpan.FromMinutes(1.0); | ||
130 | } | 131 | } |
131 | return lease; | 132 | return lease; |
132 | } | 133 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 967b835..bf86eeb 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -159,16 +159,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
159 | } | 159 | } |
160 | } | 160 | } |
161 | 161 | ||
162 | // | ||
163 | // Never expire this object | ||
164 | // | ||
165 | public override Object InitializeLifetimeService() | 162 | public override Object InitializeLifetimeService() |
166 | { | 163 | { |
167 | ILease lease = (ILease)base.InitializeLifetimeService(); | 164 | ILease lease = (ILease)base.InitializeLifetimeService(); |
168 | 165 | ||
169 | if (lease.CurrentState == LeaseState.Initial) | 166 | if (lease.CurrentState == LeaseState.Initial) |
170 | { | 167 | { |
171 | lease.InitialLeaseTime = TimeSpan.Zero; | 168 | lease.InitialLeaseTime = TimeSpan.FromMinutes(1.0); |
169 | lease.RenewOnCallTime = TimeSpan.FromSeconds(10.0); | ||
170 | lease.SponsorshipTimeout = TimeSpan.FromMinutes(1.0); | ||
172 | } | 171 | } |
173 | return lease; | 172 | return lease; |
174 | } | 173 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs index 2501752..7f67599 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs | |||
@@ -35,7 +35,7 @@ using log4net; | |||
35 | 35 | ||
36 | namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | 36 | namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase |
37 | { | 37 | { |
38 | public class Executor : MarshalByRefObject | 38 | public class Executor |
39 | { | 39 | { |
40 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 40 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
41 | 41 | ||
@@ -89,26 +89,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
89 | initEventFlags(); | 89 | initEventFlags(); |
90 | } | 90 | } |
91 | 91 | ||
92 | /// <summary> | ||
93 | /// Make sure our object does not timeout when in AppDomain. (Called by ILease base class) | ||
94 | /// </summary> | ||
95 | /// <returns></returns> | ||
96 | public override Object InitializeLifetimeService() | ||
97 | { | ||
98 | //m_log.Debug("Executor: InitializeLifetimeService()"); | ||
99 | // return null; | ||
100 | ILease lease = (ILease)base.InitializeLifetimeService(); | ||
101 | |||
102 | if (lease.CurrentState == LeaseState.Initial) | ||
103 | { | ||
104 | lease.InitialLeaseTime = TimeSpan.Zero; // TimeSpan.FromMinutes(1); | ||
105 | // lease.SponsorshipTimeout = TimeSpan.FromMinutes(2); | ||
106 | // lease.RenewOnCallTime = TimeSpan.FromSeconds(2); | ||
107 | } | ||
108 | return lease; | ||
109 | } | ||
110 | |||
111 | |||
112 | public scriptEvents GetStateEventFlags(string state) | 92 | public scriptEvents GetStateEventFlags(string state) |
113 | { | 93 | { |
114 | //m_log.Debug("Get event flags for " + state); | 94 | //m_log.Debug("Get event flags for " + state); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs index 9068634..753ca55 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs | |||
@@ -32,7 +32,7 @@ using LSLInteger = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; | |||
32 | 32 | ||
33 | namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | 33 | namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase |
34 | { | 34 | { |
35 | public partial class ScriptBaseClass : MarshalByRefObject | 35 | public partial class ScriptBaseClass |
36 | { | 36 | { |
37 | // LSL CONSTANTS | 37 | // LSL CONSTANTS |
38 | public static readonly LSLInteger TRUE = new LSLInteger(1); | 38 | public static readonly LSLInteger TRUE = new LSLInteger(1); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs index 964fe4c..d119a77 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs | |||
@@ -26,6 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Runtime.Remoting; | ||
29 | using System.Runtime.Remoting.Lifetime; | 30 | using System.Runtime.Remoting.Lifetime; |
30 | using System.Security.Permissions; | 31 | using System.Security.Permissions; |
31 | using System.Threading; | 32 | using System.Threading; |
@@ -34,26 +35,23 @@ using System.Collections; | |||
34 | using System.Collections.Generic; | 35 | using System.Collections.Generic; |
35 | using OpenSim.Region.ScriptEngine.Interfaces; | 36 | using OpenSim.Region.ScriptEngine.Interfaces; |
36 | using OpenSim.Region.ScriptEngine.Shared; | 37 | using OpenSim.Region.ScriptEngine.Shared; |
38 | using OpenSim.Region.ScriptEngine.Shared.Api.Runtime; | ||
37 | 39 | ||
38 | namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | 40 | namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase |
39 | { | 41 | { |
40 | public partial class ScriptBaseClass : MarshalByRefObject, IScript | 42 | public partial class ScriptBaseClass : MarshalByRefObject, IScript |
41 | { | 43 | { |
42 | private Dictionary<string, MethodInfo> inits = new Dictionary<string, MethodInfo>(); | 44 | private Dictionary<string, MethodInfo> inits = new Dictionary<string, MethodInfo>(); |
45 | private ScriptSponsor m_sponser; | ||
43 | 46 | ||
44 | // Object expires if we don't keep it alive | ||
45 | // sponsor will be added on object load | ||
46 | [SecurityPermissionAttribute(SecurityAction.Demand, | ||
47 | Flags = SecurityPermissionFlag.Infrastructure)] | ||
48 | public override Object InitializeLifetimeService() | 47 | public override Object InitializeLifetimeService() |
49 | { | 48 | { |
50 | ILease lease = (ILease)base.InitializeLifetimeService(); | 49 | ILease lease = (ILease)base.InitializeLifetimeService(); |
51 | if (lease.CurrentState == LeaseState.Initial) | 50 | if (lease.CurrentState == LeaseState.Initial) |
52 | { | 51 | { |
53 | lease.InitialLeaseTime = TimeSpan.Zero; | 52 | lease.InitialLeaseTime = TimeSpan.FromMinutes(1.0); |
54 | // lease.InitialLeaseTime = TimeSpan.FromMinutes(1); | 53 | lease.RenewOnCallTime = TimeSpan.FromSeconds(10.0); |
55 | // lease.SponsorshipTimeout = TimeSpan.FromMinutes(2); | 54 | lease.SponsorshipTimeout = TimeSpan.FromMinutes(1.0); |
56 | // lease.RenewOnCallTime = TimeSpan.FromSeconds(2); | ||
57 | } | 55 | } |
58 | return lease; | 56 | return lease; |
59 | } | 57 | } |
@@ -66,7 +64,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
66 | } | 64 | } |
67 | #endif | 65 | #endif |
68 | 66 | ||
69 | |||
70 | public ScriptBaseClass() | 67 | public ScriptBaseClass() |
71 | { | 68 | { |
72 | m_Executor = new Executor(this); | 69 | m_Executor = new Executor(this); |
@@ -81,6 +78,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
81 | inits[type] = mi; | 78 | inits[type] = mi; |
82 | } | 79 | } |
83 | } | 80 | } |
81 | |||
82 | m_sponser = new ScriptSponsor(); | ||
84 | } | 83 | } |
85 | 84 | ||
86 | private Executor m_Executor = null; | 85 | private Executor m_Executor = null; |
@@ -112,6 +111,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
112 | if (!inits.ContainsKey(api)) | 111 | if (!inits.ContainsKey(api)) |
113 | return; | 112 | return; |
114 | 113 | ||
114 | ILease lease = (ILease)RemotingServices.GetLifetimeService(data as MarshalByRefObject); | ||
115 | lease.Register(m_sponser); | ||
116 | |||
115 | MethodInfo mi = inits[api]; | 117 | MethodInfo mi = inits[api]; |
116 | 118 | ||
117 | Object[] args = new Object[1]; | 119 | Object[] args = new Object[1]; |
@@ -122,6 +124,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
122 | m_InitialValues = GetVars(); | 124 | m_InitialValues = GetVars(); |
123 | } | 125 | } |
124 | 126 | ||
127 | public void Close() | ||
128 | { | ||
129 | m_sponser.Close(); | ||
130 | } | ||
131 | |||
125 | public Dictionary<string, object> GetVars() | 132 | public Dictionary<string, object> GetVars() |
126 | { | 133 | { |
127 | Dictionary<string, object> vars = new Dictionary<string, object>(); | 134 | Dictionary<string, object> vars = new Dictionary<string, object>(); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptSponsor.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptSponsor.cs index a2da14e..977ac30 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptSponsor.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptSponsor.cs | |||
@@ -32,15 +32,19 @@ using System.Text; | |||
32 | 32 | ||
33 | namespace OpenSim.Region.ScriptEngine.Shared.Api.Runtime | 33 | namespace OpenSim.Region.ScriptEngine.Shared.Api.Runtime |
34 | { | 34 | { |
35 | [Serializable] | ||
36 | public class ScriptSponsor : MarshalByRefObject, ISponsor | 35 | public class ScriptSponsor : MarshalByRefObject, ISponsor |
37 | { | 36 | { |
38 | // In theory: I execute, therefore I am. | 37 | private bool m_closed = false; |
39 | // If GC collects this class then sponsorship will expire | 38 | |
40 | public TimeSpan Renewal(ILease lease) | 39 | public TimeSpan Renewal(ILease lease) |
41 | { | 40 | { |
42 | return TimeSpan.FromMinutes(2); | 41 | if (!m_closed) |
42 | return lease.InitialLeaseTime; | ||
43 | return TimeSpan.FromTicks(0); | ||
43 | } | 44 | } |
45 | |||
46 | public void Close() { m_closed = true; } | ||
47 | |||
44 | #if DEBUG | 48 | #if DEBUG |
45 | // For tracing GC while debugging | 49 | // For tracing GC while debugging |
46 | public static bool GCDummy = false; | 50 | public static bool GCDummy = false; |