aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine')
-rw-r--r--OpenSim/Region/ScriptEngine/Interfaces/IScript.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs5
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs7
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs22
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs25
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptSponsor.cs12
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs25
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/XEngine.cs14
9 files changed, 55 insertions, 59 deletions
diff --git a/OpenSim/Region/ScriptEngine/Interfaces/IScript.cs b/OpenSim/Region/ScriptEngine/Interfaces/IScript.cs
index 726dabc..b9618d1 100644
--- a/OpenSim/Region/ScriptEngine/Interfaces/IScript.cs
+++ b/OpenSim/Region/ScriptEngine/Interfaces/IScript.cs
@@ -41,7 +41,5 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
41 Dictionary<string,Object> GetVars(); 41 Dictionary<string,Object> GetVars();
42 void SetVars(Dictionary<string,Object> vars); 42 void SetVars(Dictionary<string,Object> vars);
43 void ResetVars(); 43 void ResetVars();
44
45 void Close();
46 } 44 }
47} 45}
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
36namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase 36namespace 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
33namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase 33namespace 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
28using System; 28using System;
29using System.Runtime.Remoting;
30using System.Runtime.Remoting.Lifetime; 29using System.Runtime.Remoting.Lifetime;
31using System.Security.Permissions; 30using System.Security.Permissions;
32using System.Threading; 31using System.Threading;
@@ -35,23 +34,26 @@ using System.Collections;
35using System.Collections.Generic; 34using System.Collections.Generic;
36using OpenSim.Region.ScriptEngine.Interfaces; 35using OpenSim.Region.ScriptEngine.Interfaces;
37using OpenSim.Region.ScriptEngine.Shared; 36using OpenSim.Region.ScriptEngine.Shared;
38using OpenSim.Region.ScriptEngine.Shared.Api.Runtime;
39 37
40namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase 38namespace 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
33namespace OpenSim.Region.ScriptEngine.Shared.Api.Runtime 33namespace 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);
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index ff75e2f..c7673c7 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -272,10 +272,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine
272 instance.ClearQueue(); 272 instance.ClearQueue();
273 instance.Stop(0); 273 instance.Stop(0);
274 274
275 // Release events, timer, etc
276 //
277 instance.DestroyScriptInstance();
278
279 // Unload scripts and app domains 275 // Unload scripts and app domains
280 // Must be done explicitly because they have infinite 276 // Must be done explicitly because they have infinite
281 // lifetime 277 // lifetime
@@ -286,6 +282,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine
286 m_DomainScripts.Remove(instance.AppDomain); 282 m_DomainScripts.Remove(instance.AppDomain);
287 UnloadAppDomain(instance.AppDomain); 283 UnloadAppDomain(instance.AppDomain);
288 } 284 }
285
286 // Release events, timer, etc
287 //
288 instance.DestroyScriptInstance();
289 } 289 }
290 m_Scripts.Clear(); 290 m_Scripts.Clear();
291 m_PrimObjects.Clear(); 291 m_PrimObjects.Clear();
@@ -802,9 +802,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine
802 } 802 }
803 } 803 }
804 804
805 instance.RemoveState();
806 instance.DestroyScriptInstance();
807
808 m_DomainScripts[instance.AppDomain].Remove(instance.ItemID); 805 m_DomainScripts[instance.AppDomain].Remove(instance.ItemID);
809 if (m_DomainScripts[instance.AppDomain].Count == 0) 806 if (m_DomainScripts[instance.AppDomain].Count == 0)
810 { 807 {
@@ -812,6 +809,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine
812 UnloadAppDomain(instance.AppDomain); 809 UnloadAppDomain(instance.AppDomain);
813 } 810 }
814 811
812 instance.RemoveState();
813 instance.DestroyScriptInstance();
814
815 instance = null; 815 instance = null;
816 816
817 ObjectRemoved handlerObjectRemoved = OnObjectRemoved; 817 ObjectRemoved handlerObjectRemoved = OnObjectRemoved;