diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
index 887a31765a..229180fe87 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
@@ -241,7 +241,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
if (Engine.Config.GetString("ScriptStopStrategy", "abort") == "co-op")
{
m_coopTermination = true;
- m_coopSleepHandle = new AutoResetEvent(false);
+ m_coopSleepHandle = new XEngineEventWaitHandle(false, EventResetMode.AutoReset);
}
}
@@ -1201,4 +1201,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
Suspended = false;
}
}
-}
+
+ ///
+ /// Xengine event wait handle.
+ ///
+ ///
+ /// This class exists becase XEngineScriptBase gets a reference to this wait handle. We need to make sure that
+ /// when scripts are running in different AppDomains the lease does not expire.
+ /// FIXME: Like LSL_Api, etc., this effectively leaks memory since the GC will never collect it. To avoid this,
+ /// proper remoting sponsorship needs to be implemented across the board.
+ ///
+ public class XEngineEventWaitHandle : EventWaitHandle
+ {
+ public XEngineEventWaitHandle(bool initialState, EventResetMode mode) : base(initialState, mode) {}
+
+ public override Object InitializeLifetimeService()
+ {
+ return null;
+ }
+ }
+}
\ No newline at end of file