From e6ddb5de7de4ed61fa19b3805cd77104328eb20a Mon Sep 17 00:00:00 2001 From: Tedd Hansen Date: Wed, 26 Nov 2008 11:12:57 +0000 Subject: 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! :) --- OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs') 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 @@ using System; using System.IO; +using System.Runtime.Remoting; +using System.Runtime.Remoting.Lifetime; using System.Threading; using System.Collections; using System.Collections.Generic; @@ -44,6 +46,7 @@ using OpenSim.Region.Environment.Scenes; using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.ScriptEngine.Shared; using OpenSim.Region.ScriptEngine.Shared.Api; +using OpenSim.Region.ScriptEngine.Shared.Api.Runtime; using OpenSim.Region.ScriptEngine.Shared.ScriptBase; using OpenSim.Region.ScriptEngine.Shared.CodeTools; using OpenSim.Region.ScriptEngine.Interfaces; @@ -80,6 +83,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance private int m_ControlEventsInQueue = 0; private int m_LastControlLevel = 0; private bool m_CollisionInQueue = false; + private ISponsor m_ScriptSponsor; private Dictionary, KeyValuePair> m_LineMap; @@ -204,6 +208,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance m_Script = (IScript)dom.CreateInstanceAndUnwrap( Path.GetFileNameWithoutExtension(assembly), "SecondLife.Script"); + + // Add a sponsor to the script + ISponsor scriptSponsor = new ScriptSponsor(); + ILease lease = (ILease)RemotingServices.GetLifetimeService(m_Script as MarshalByRefObject); + lease.Register(scriptSponsor); + m_ScriptSponsor = scriptSponsor; + } catch (Exception e) { -- cgit v1.1