diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/XEngine/XEngine.cs')
-rw-r--r-- | OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 67 |
1 files changed, 58 insertions, 9 deletions
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 5317cf1..4b9affc 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | |||
@@ -52,14 +52,14 @@ using OpenSim.Region.ScriptEngine.Interfaces; | |||
52 | 52 | ||
53 | namespace OpenSim.Region.ScriptEngine.XEngine | 53 | namespace OpenSim.Region.ScriptEngine.XEngine |
54 | { | 54 | { |
55 | public class XEngine : IRegionModule, IScriptModule, IScriptEngine | 55 | public class XEngine : INonSharedRegionModule, IScriptModule, IScriptEngine |
56 | { | 56 | { |
57 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 57 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
58 | 58 | ||
59 | private SmartThreadPool m_ThreadPool; | 59 | private SmartThreadPool m_ThreadPool; |
60 | private int m_MaxScriptQueue; | 60 | private int m_MaxScriptQueue; |
61 | private Scene m_Scene; | 61 | private Scene m_Scene; |
62 | private IConfig m_ScriptConfig; | 62 | private IConfig m_ScriptConfig = null; |
63 | private ICompiler m_Compiler; | 63 | private ICompiler m_Compiler; |
64 | private int m_MinThreads; | 64 | private int m_MinThreads; |
65 | private int m_MaxThreads ; | 65 | private int m_MaxThreads ; |
@@ -154,9 +154,18 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
154 | // | 154 | // |
155 | // IRegionModule functions | 155 | // IRegionModule functions |
156 | // | 156 | // |
157 | public void Initialise(Scene scene, IConfigSource configSource) | 157 | public void Initialise(IConfigSource configSource) |
158 | { | 158 | { |
159 | if (configSource.Configs["XEngine"] == null) | ||
160 | return; | ||
161 | |||
159 | m_ScriptConfig = configSource.Configs["XEngine"]; | 162 | m_ScriptConfig = configSource.Configs["XEngine"]; |
163 | } | ||
164 | |||
165 | public void AddRegion(Scene scene) | ||
166 | { | ||
167 | if (m_ScriptConfig == null) | ||
168 | return; | ||
160 | m_ScriptFailCount = 0; | 169 | m_ScriptFailCount = 0; |
161 | m_ScriptErrorMessage = String.Empty; | 170 | m_ScriptErrorMessage = String.Empty; |
162 | 171 | ||
@@ -237,7 +246,52 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
237 | } | 246 | } |
238 | } | 247 | } |
239 | 248 | ||
240 | public void PostInitialise() | 249 | public void RemoveRegion(Scene scene) |
250 | { | ||
251 | lock (m_Scripts) | ||
252 | { | ||
253 | foreach (IScriptInstance instance in m_Scripts.Values) | ||
254 | { | ||
255 | // Force a final state save | ||
256 | // | ||
257 | if (m_Assemblies.ContainsKey(instance.AssetID)) | ||
258 | { | ||
259 | string assembly = m_Assemblies[instance.AssetID]; | ||
260 | instance.SaveState(assembly); | ||
261 | } | ||
262 | |||
263 | // Clear the event queue and abort the instance thread | ||
264 | // | ||
265 | instance.ClearQueue(); | ||
266 | instance.Stop(0); | ||
267 | |||
268 | // Unload scripts and app domains | ||
269 | // Must be done explicitly because they have infinite | ||
270 | // lifetime | ||
271 | // | ||
272 | m_DomainScripts[instance.AppDomain].Remove(instance.ItemID); | ||
273 | if (m_DomainScripts[instance.AppDomain].Count == 0) | ||
274 | { | ||
275 | m_DomainScripts.Remove(instance.AppDomain); | ||
276 | UnloadAppDomain(instance.AppDomain); | ||
277 | } | ||
278 | |||
279 | // Release events, timer, etc | ||
280 | // | ||
281 | instance.DestroyScriptInstance(); | ||
282 | } | ||
283 | m_Scripts.Clear(); | ||
284 | m_PrimObjects.Clear(); | ||
285 | m_Assemblies.Clear(); | ||
286 | m_DomainScripts.Clear(); | ||
287 | } | ||
288 | lock (m_ScriptEngines) | ||
289 | { | ||
290 | m_ScriptEngines.Remove(this); | ||
291 | } | ||
292 | } | ||
293 | |||
294 | public void RegionLoaded(Scene scene) | ||
241 | { | 295 | { |
242 | if (!m_Enabled) | 296 | if (!m_Enabled) |
243 | return; | 297 | return; |
@@ -346,11 +400,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
346 | get { return "XEngine"; } | 400 | get { return "XEngine"; } |
347 | } | 401 | } |
348 | 402 | ||
349 | public bool IsSharedModule | ||
350 | { | ||
351 | get { return false; } | ||
352 | } | ||
353 | |||
354 | public void OnRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource) | 403 | public void OnRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource) |
355 | { | 404 | { |
356 | if (script.StartsWith("//MRM:")) | 405 | if (script.StartsWith("//MRM:")) |