diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared')
7 files changed, 48 insertions, 50 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 5f9b09b..bc36fda 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -119,15 +119,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
119 | AsyncCommands = new AsyncCommandManager(ScriptEngine); | 119 | AsyncCommands = new AsyncCommandManager(ScriptEngine); |
120 | } | 120 | } |
121 | 121 | ||
122 | // Object never expires | ||
122 | public override Object InitializeLifetimeService() | 123 | public override Object InitializeLifetimeService() |
123 | { | 124 | { |
124 | ILease lease = (ILease)base.InitializeLifetimeService(); | 125 | ILease lease = (ILease)base.InitializeLifetimeService(); |
125 | 126 | ||
126 | if (lease.CurrentState == LeaseState.Initial) | 127 | if (lease.CurrentState == LeaseState.Initial) |
127 | { | 128 | { |
128 | lease.InitialLeaseTime = TimeSpan.FromMinutes(1.0); | 129 | lease.InitialLeaseTime = TimeSpan.Zero; |
129 | lease.RenewOnCallTime = TimeSpan.FromSeconds(10.0); | ||
130 | lease.SponsorshipTimeout = TimeSpan.FromMinutes(1.0); | ||
131 | } | 130 | } |
132 | return lease; | 131 | return lease; |
133 | } | 132 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index b447cfb..7c878b8 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -159,15 +159,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
159 | } | 159 | } |
160 | } | 160 | } |
161 | 161 | ||
162 | // | ||
163 | // Never expire this object | ||
164 | // | ||
162 | public override Object InitializeLifetimeService() | 165 | public override Object InitializeLifetimeService() |
163 | { | 166 | { |
164 | ILease lease = (ILease)base.InitializeLifetimeService(); | 167 | ILease lease = (ILease)base.InitializeLifetimeService(); |
165 | 168 | ||
166 | if (lease.CurrentState == LeaseState.Initial) | 169 | if (lease.CurrentState == LeaseState.Initial) |
167 | { | 170 | { |
168 | lease.InitialLeaseTime = TimeSpan.FromMinutes(1.0); | 171 | lease.InitialLeaseTime = TimeSpan.Zero; |
169 | lease.RenewOnCallTime = TimeSpan.FromSeconds(10.0); | ||
170 | lease.SponsorshipTimeout = TimeSpan.FromMinutes(1.0); | ||
171 | } | 172 | } |
172 | return lease; | 173 | return lease; |
173 | } | 174 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs index 7f67599..2501752 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 | 38 | public class Executor : MarshalByRefObject |
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,6 +89,26 @@ 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 | |||
92 | public scriptEvents GetStateEventFlags(string state) | 112 | public scriptEvents GetStateEventFlags(string state) |
93 | { | 113 | { |
94 | //m_log.Debug("Get event flags for " + state); | 114 | //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 753ca55..9068634 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 | 35 | public partial class ScriptBaseClass : MarshalByRefObject |
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 d119a77..964fe4c 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs | |||
@@ -26,7 +26,6 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Runtime.Remoting; | ||
30 | using System.Runtime.Remoting.Lifetime; | 29 | using System.Runtime.Remoting.Lifetime; |
31 | using System.Security.Permissions; | 30 | using System.Security.Permissions; |
32 | using System.Threading; | 31 | using System.Threading; |
@@ -35,23 +34,26 @@ using System.Collections; | |||
35 | using System.Collections.Generic; | 34 | using System.Collections.Generic; |
36 | using OpenSim.Region.ScriptEngine.Interfaces; | 35 | using OpenSim.Region.ScriptEngine.Interfaces; |
37 | using OpenSim.Region.ScriptEngine.Shared; | 36 | using OpenSim.Region.ScriptEngine.Shared; |
38 | using OpenSim.Region.ScriptEngine.Shared.Api.Runtime; | ||
39 | 37 | ||
40 | namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | 38 | namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase |
41 | { | 39 | { |
42 | public partial class ScriptBaseClass : MarshalByRefObject, IScript | 40 | public partial class ScriptBaseClass : MarshalByRefObject, IScript |
43 | { | 41 | { |
44 | private Dictionary<string, MethodInfo> inits = new Dictionary<string, MethodInfo>(); | 42 | private Dictionary<string, MethodInfo> inits = new Dictionary<string, MethodInfo>(); |
45 | private ScriptSponsor m_sponser; | ||
46 | 43 | ||
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)] | ||
47 | public override Object InitializeLifetimeService() | 48 | public override Object InitializeLifetimeService() |
48 | { | 49 | { |
49 | ILease lease = (ILease)base.InitializeLifetimeService(); | 50 | ILease lease = (ILease)base.InitializeLifetimeService(); |
50 | if (lease.CurrentState == LeaseState.Initial) | 51 | if (lease.CurrentState == LeaseState.Initial) |
51 | { | 52 | { |
52 | lease.InitialLeaseTime = TimeSpan.FromMinutes(1.0); | 53 | lease.InitialLeaseTime = TimeSpan.Zero; |
53 | lease.RenewOnCallTime = TimeSpan.FromSeconds(10.0); | 54 | // lease.InitialLeaseTime = TimeSpan.FromMinutes(1); |
54 | lease.SponsorshipTimeout = TimeSpan.FromMinutes(1.0); | 55 | // lease.SponsorshipTimeout = TimeSpan.FromMinutes(2); |
56 | // lease.RenewOnCallTime = TimeSpan.FromSeconds(2); | ||
55 | } | 57 | } |
56 | return lease; | 58 | return lease; |
57 | } | 59 | } |
@@ -64,6 +66,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
64 | } | 66 | } |
65 | #endif | 67 | #endif |
66 | 68 | ||
69 | |||
67 | public ScriptBaseClass() | 70 | public ScriptBaseClass() |
68 | { | 71 | { |
69 | m_Executor = new Executor(this); | 72 | m_Executor = new Executor(this); |
@@ -78,8 +81,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
78 | inits[type] = mi; | 81 | inits[type] = mi; |
79 | } | 82 | } |
80 | } | 83 | } |
81 | |||
82 | m_sponser = new ScriptSponsor(); | ||
83 | } | 84 | } |
84 | 85 | ||
85 | private Executor m_Executor = null; | 86 | private Executor m_Executor = null; |
@@ -111,9 +112,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
111 | if (!inits.ContainsKey(api)) | 112 | if (!inits.ContainsKey(api)) |
112 | return; | 113 | return; |
113 | 114 | ||
114 | ILease lease = (ILease)RemotingServices.GetLifetimeService(data as MarshalByRefObject); | ||
115 | lease.Register(m_sponser); | ||
116 | |||
117 | MethodInfo mi = inits[api]; | 115 | MethodInfo mi = inits[api]; |
118 | 116 | ||
119 | Object[] args = new Object[1]; | 117 | Object[] args = new Object[1]; |
@@ -124,11 +122,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
124 | m_InitialValues = GetVars(); | 122 | m_InitialValues = GetVars(); |
125 | } | 123 | } |
126 | 124 | ||
127 | public void Close() | ||
128 | { | ||
129 | m_sponser.Close(); | ||
130 | } | ||
131 | |||
132 | public Dictionary<string, object> GetVars() | 125 | public Dictionary<string, object> GetVars() |
133 | { | 126 | { |
134 | Dictionary<string, object> vars = new Dictionary<string, object>(); | 127 | 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 977ac30..a2da14e 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptSponsor.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptSponsor.cs | |||
@@ -32,19 +32,15 @@ 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] | ||
35 | public class ScriptSponsor : MarshalByRefObject, ISponsor | 36 | public class ScriptSponsor : MarshalByRefObject, ISponsor |
36 | { | 37 | { |
37 | private bool m_closed = false; | 38 | // In theory: I execute, therefore I am. |
38 | 39 | // If GC collects this class then sponsorship will expire | |
39 | public TimeSpan Renewal(ILease lease) | 40 | public TimeSpan Renewal(ILease lease) |
40 | { | 41 | { |
41 | if (!m_closed) | 42 | return TimeSpan.FromMinutes(2); |
42 | return lease.InitialLeaseTime; | ||
43 | return TimeSpan.FromTicks(0); | ||
44 | } | 43 | } |
45 | |||
46 | public void Close() { m_closed = true; } | ||
47 | |||
48 | #if DEBUG | 44 | #if DEBUG |
49 | // For tracing GC while debugging | 45 | // For tracing GC while debugging |
50 | public static bool GCDummy = false; | 46 | public static bool GCDummy = false; |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index 6d62249..8168300 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | |||
@@ -96,8 +96,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
96 | private string m_CurrentState = String.Empty; | 96 | private string m_CurrentState = String.Empty; |
97 | private UUID m_RegionID = UUID.Zero; | 97 | private UUID m_RegionID = UUID.Zero; |
98 | 98 | ||
99 | private ScriptSponsor m_ScriptSponsor; | 99 | //private ISponsor m_ScriptSponsor; |
100 | private bool m_destroyed = false; | ||
101 | private Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> | 100 | private Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> |
102 | m_LineMap; | 101 | m_LineMap; |
103 | 102 | ||
@@ -262,9 +261,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
262 | Path.GetFileNameWithoutExtension(assembly), | 261 | Path.GetFileNameWithoutExtension(assembly), |
263 | "SecondLife.Script"); | 262 | "SecondLife.Script"); |
264 | 263 | ||
265 | m_ScriptSponsor = new ScriptSponsor(); | 264 | // Add a sponsor to the script |
266 | ILease lease = (ILease)RemotingServices.GetLifetimeService(m_Script as ScriptBaseClass); | 265 | // ISponsor scriptSponsor = new ScriptSponsor(); |
267 | lease.Register(m_ScriptSponsor); | 266 | // ILease lease = (ILease)RemotingServices.GetLifetimeService(m_Script as MarshalByRefObject); |
267 | // lease.Register(scriptSponsor); | ||
268 | //m_ScriptSponsor = scriptSponsor; | ||
269 | |||
268 | } | 270 | } |
269 | catch (Exception) | 271 | catch (Exception) |
270 | { | 272 | { |
@@ -447,13 +449,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
447 | { | 449 | { |
448 | ReleaseControls(); | 450 | ReleaseControls(); |
449 | AsyncCommandManager.RemoveScript(m_Engine, m_LocalID, m_ItemID); | 451 | AsyncCommandManager.RemoveScript(m_Engine, m_LocalID, m_ItemID); |
450 | |||
451 | m_Script.Close(); | ||
452 | m_ScriptSponsor.Close(); | ||
453 | ILease lease = (ILease)RemotingServices.GetLifetimeService(m_Script as ScriptBaseClass); | ||
454 | lease.Unregister(m_ScriptSponsor); | ||
455 | |||
456 | m_destroyed = true; | ||
457 | } | 452 | } |
458 | 453 | ||
459 | public void RemoveState() | 454 | public void RemoveState() |
@@ -889,8 +884,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
889 | 884 | ||
890 | public void SaveState(string assembly) | 885 | public void SaveState(string assembly) |
891 | { | 886 | { |
892 | |||
893 | |||
894 | // If we're currently in an event, just tell it to save upon return | 887 | // If we're currently in an event, just tell it to save upon return |
895 | // | 888 | // |
896 | if (m_InEvent) | 889 | if (m_InEvent) |
@@ -899,10 +892,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
899 | return; | 892 | return; |
900 | } | 893 | } |
901 | 894 | ||
902 | // Data may not be available as the script has already been destroyed | ||
903 | if (m_destroyed == true) | ||
904 | return; | ||
905 | |||
906 | PluginData = AsyncCommandManager.GetSerializationData(m_Engine, m_ItemID); | 895 | PluginData = AsyncCommandManager.GetSerializationData(m_Engine, m_ItemID); |
907 | 896 | ||
908 | string xml = ScriptSerializer.Serialize(this); | 897 | string xml = ScriptSerializer.Serialize(this); |