diff options
author | Melanie Thielker | 2009-04-15 18:51:17 +0000 |
---|---|---|
committer | Melanie Thielker | 2009-04-15 18:51:17 +0000 |
commit | 3c338e4e563509e480d5eab71134126d1d7aadf5 (patch) | |
tree | 8a6c038d859f41a97d857770dc626d38d8a8cd3a /OpenSim | |
parent | * Resolve unit test failure introduced in r9148 (probably) (diff) | |
download | opensim-SC-3c338e4e563509e480d5eab71134126d1d7aadf5.zip opensim-SC-3c338e4e563509e480d5eab71134126d1d7aadf5.tar.gz opensim-SC-3c338e4e563509e480d5eab71134126d1d7aadf5.tar.bz2 opensim-SC-3c338e4e563509e480d5eab71134126d1d7aadf5.tar.xz |
Convert both script engines to new region module format. Add proper unload
handling to XEngine. Add needed stubs to DotNetEngine.
Diffstat (limited to 'OpenSim')
7 files changed, 83 insertions, 17 deletions
diff --git a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs index 51dcb7d..6265683 100644 --- a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs | |||
@@ -30,7 +30,7 @@ using OpenMetaverse; | |||
30 | 30 | ||
31 | namespace OpenSim.Region.Framework.Interfaces | 31 | namespace OpenSim.Region.Framework.Interfaces |
32 | { | 32 | { |
33 | public interface IScriptModule : IRegionModule | 33 | public interface IScriptModule: INonSharedRegionModule |
34 | { | 34 | { |
35 | string ScriptEngineName { get; } | 35 | string ScriptEngineName { get; } |
36 | 36 | ||
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs index 23acc08..f7a9648 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs | |||
@@ -43,7 +43,7 @@ using OpenSim.Region.ScriptEngine.Shared.ScriptBase; | |||
43 | namespace OpenSim.Region.ScriptEngine.DotNetEngine | 43 | namespace OpenSim.Region.ScriptEngine.DotNetEngine |
44 | { | 44 | { |
45 | [Serializable] | 45 | [Serializable] |
46 | public class ScriptEngine : IRegionModule, IScriptEngine, IScriptModule | 46 | public class ScriptEngine : INonSharedRegionModule, IScriptEngine, IScriptModule |
47 | { | 47 | { |
48 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 48 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
49 | 49 | ||
@@ -117,11 +117,15 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine | |||
117 | } | 117 | } |
118 | } | 118 | } |
119 | 119 | ||
120 | public void Initialise(Scene Sceneworld, IConfigSource config) | 120 | public void Initialise(IConfigSource config) |
121 | { | ||
122 | ConfigSource = config; | ||
123 | } | ||
124 | |||
125 | public void AddRegion(Scene Sceneworld) | ||
121 | { | 126 | { |
122 | m_log.Info("[" + ScriptEngineName + "]: ScriptEngine initializing"); | 127 | m_log.Info("[" + ScriptEngineName + "]: ScriptEngine initializing"); |
123 | 128 | ||
124 | ConfigSource = config; | ||
125 | m_Scene = Sceneworld; | 129 | m_Scene = Sceneworld; |
126 | 130 | ||
127 | // Make sure we have config | 131 | // Make sure we have config |
@@ -153,7 +157,11 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine | |||
153 | m_Scene.StackModuleInterface<IScriptModule>(this); | 157 | m_Scene.StackModuleInterface<IScriptModule>(this); |
154 | } | 158 | } |
155 | 159 | ||
156 | public void PostInitialise() | 160 | public void RemoveRegion(Scene scene) |
161 | { | ||
162 | } | ||
163 | |||
164 | public void RegionLoaded(Scene scene) | ||
157 | { | 165 | { |
158 | if (!m_enabled) | 166 | if (!m_enabled) |
159 | return; | 167 | return; |
diff --git a/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs b/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs index 017a6ba..44d5cbe 100644 --- a/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs | |||
@@ -104,5 +104,6 @@ namespace OpenSim.Region.ScriptEngine.Interfaces | |||
104 | string GetAssemblyName(); | 104 | string GetAssemblyName(); |
105 | string GetXMLState(); | 105 | string GetXMLState(); |
106 | double MinEventDelay { set; } | 106 | double MinEventDelay { set; } |
107 | UUID RegionID { get; } | ||
107 | } | 108 | } |
108 | } | 109 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index 1c865e8..8e3d026 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | |||
@@ -93,6 +93,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
93 | private bool m_postOnRez; | 93 | private bool m_postOnRez; |
94 | private bool m_startedFromSavedState = false; | 94 | private bool m_startedFromSavedState = false; |
95 | private string m_CurrentState = String.Empty; | 95 | private string m_CurrentState = String.Empty; |
96 | private UUID m_RegionID = UUID.Zero; | ||
96 | 97 | ||
97 | //private ISponsor m_ScriptSponsor; | 98 | //private ISponsor m_ScriptSponsor; |
98 | private Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> | 99 | private Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> |
@@ -231,6 +232,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
231 | m_MaxScriptQueue = maxScriptQueue; | 232 | m_MaxScriptQueue = maxScriptQueue; |
232 | m_stateSource = stateSource; | 233 | m_stateSource = stateSource; |
233 | m_postOnRez = postOnRez; | 234 | m_postOnRez = postOnRez; |
235 | m_RegionID = part.ParentGroup.Scene.RegionInfo.RegionID; | ||
234 | 236 | ||
235 | if (part != null) | 237 | if (part != null) |
236 | { | 238 | { |
@@ -980,5 +982,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
980 | 982 | ||
981 | return ScriptSerializer.Serialize(this); | 983 | return ScriptSerializer.Serialize(this); |
982 | } | 984 | } |
985 | |||
986 | public UUID RegionID | ||
987 | { | ||
988 | get { return m_RegionID; } | ||
989 | } | ||
983 | } | 990 | } |
984 | } | 991 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs index cf98cf1..9fe48df 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs | |||
@@ -60,7 +60,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
60 | SceneObjectPart part = SceneSetupHelpers.AddSceneObject(scene); | 60 | SceneObjectPart part = SceneSetupHelpers.AddSceneObject(scene); |
61 | 61 | ||
62 | XEngine.XEngine engine = new XEngine.XEngine(); | 62 | XEngine.XEngine engine = new XEngine.XEngine(); |
63 | engine.Initialise(scene, initConfigSource); | 63 | engine.Initialise(initConfigSource); |
64 | engine.AddRegion(scene); | ||
64 | 65 | ||
65 | m_lslApi = new LSL_Api(); | 66 | m_lslApi = new LSL_Api(); |
66 | m_lslApi.Initialize(engine, part, part.LocalId, part.UUID); | 67 | m_lslApi.Initialize(engine, part, part.LocalId, part.UUID); |
diff --git a/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineTest.cs b/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineTest.cs index 663b0ca..402fb2f 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineTest.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineTest.cs | |||
@@ -60,9 +60,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine.Tests | |||
60 | [Test] | 60 | [Test] |
61 | public void T001_XStart() | 61 | public void T001_XStart() |
62 | { | 62 | { |
63 | IRegionModule xengine = new XEngine(); | 63 | INonSharedRegionModule xengine = new XEngine(); |
64 | SceneSetupHelpers.SetupSceneModules(scene, new IniConfigSource(), xengine); | 64 | SceneSetupHelpers.SetupSceneModules(scene, new IniConfigSource(), xengine); |
65 | xengine.PostInitialise(); | 65 | xengine.RegionLoaded(scene); |
66 | } | 66 | } |
67 | } | 67 | } |
68 | } | 68 | } |
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:")) |