From 667197f24d1b9b050f1067f8a1fa757b7d46fdf6 Mon Sep 17 00:00:00 2001 From: Tedd Hansen Date: Sat, 2 Feb 2008 00:59:22 +0000 Subject: [PATCH] Added OpenSim.32BitLaunch.exe that can be used on 64-bit systems to run OpenSim in 32-bit mode. Fixed ScriptEngine.Common startup problems. --- OpenSim/Grid/ScriptServer/ScriptServerMain.cs | 5 +-- .../ScriptEngineBase/EventQueueManager.cs | 36 ++++++++++--------- .../Common/ScriptEngineBase/ScriptEngine.cs | 11 ++++-- .../Common/ScriptServerInterfaces.cs | 3 +- .../ScriptEngine/DotNetEngine/ScriptEngine.cs | 2 +- .../DotNetEngine/ScriptManager.cs | 16 ++++----- .../ScriptEngine/LSOEngine/ScriptEngine.cs | 2 +- prebuild.xml | 1 + 8 files changed, 44 insertions(+), 32 deletions(-) diff --git a/OpenSim/Grid/ScriptServer/ScriptServerMain.cs b/OpenSim/Grid/ScriptServer/ScriptServerMain.cs index d75cff7885..5757be4cca 100644 --- a/OpenSim/Grid/ScriptServer/ScriptServerMain.cs +++ b/OpenSim/Grid/ScriptServer/ScriptServerMain.cs @@ -28,6 +28,7 @@ using System.IO; using libsecondlife; +using Nini.Config; using OpenSim.Framework; using OpenSim.Framework.Console; using OpenSim.Grid.ScriptServer.ScriptServer; @@ -66,8 +67,8 @@ namespace OpenSim.Grid.ScriptServer // Load DotNetEngine Engine = ScriptEngines.LoadEngine("DotNetEngine"); - - Engine.InitializeEngine(null, m_log, false, Engine.GetScriptManager()); + IConfigSource config = null; + Engine.InitializeEngine(null, null, m_log, false, Engine.GetScriptManager()); // Set up server diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueManager.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueManager.cs index 7b10713922..fb20f4059f 100644 --- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueManager.cs +++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueManager.cs @@ -75,7 +75,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase /// Locking access to eventQueueThreads AND staticGlobalEventQueueThreads. /// Note that this may or may not be a reference to a static object depending on PrivateRegionThreads config setting. /// - private object eventQueueThreadsLock; + private object eventQueueThreadsLock = new object(); // Static objects for referencing the objects above if we don't have private threads: internal static List staticEventQueueThreads; // A static reference used if we don't use private threads internal static object staticEventQueueThreadsLock; // Statick lock object reference for same reason @@ -173,10 +173,11 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase { m_ScriptEngine = _ScriptEngine; + bool PrivateRegionThreads = m_ScriptEngine.ScriptConfigSource.GetBoolean("PrivateRegionThreads", false); // Create thread pool list and lock object // Determine from config if threads should be dedicated to regions or shared - if (m_ScriptEngine.ScriptConfigSource.GetBoolean("PrivateRegionThreads", false)) + if (PrivateRegionThreads) { // PRIVATE THREAD POOL PER REGION eventQueueThreads = new List(); @@ -185,13 +186,13 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase else { // SHARED THREAD POOL - // Crate the objects in statics + // Crate the static objects if (staticEventQueueThreads == null) staticEventQueueThreads = new List(); if (staticEventQueueThreadsLock == null) staticEventQueueThreadsLock = new object(); - // Create local reference to them + // Now reference our locals to them eventQueueThreads = staticEventQueueThreads; eventQueueThreadsLock = staticEventQueueThreadsLock; } @@ -228,22 +229,25 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase private void Stop() { - - // Kill worker threads - lock (eventQueueThreadsLock) + if (eventQueueThreadsLock != null && eventQueueThreads != null) { - foreach (EventQueueThreadClass EventQueueThread in eventQueueThreads) + // Kill worker threads + lock (eventQueueThreadsLock) { - AbortThreadClass(EventQueueThread); + foreach (EventQueueThreadClass EventQueueThread in eventQueueThreads) + { + AbortThreadClass(EventQueueThread); + } + eventQueueThreads.Clear(); + staticGlobalEventQueueThreads.Clear(); } - eventQueueThreads.Clear(); - staticGlobalEventQueueThreads.Clear(); - } - // Remove all entries from our event queue - lock (queueLock) - { - eventQueue.Clear(); } + + // Remove all entries from our event queue + lock (queueLock) + { + eventQueue.Clear(); + } } #endregion diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptEngine.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptEngine.cs index a6d10198a4..ea8ae1f907 100644 --- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptEngine.cs +++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptEngine.cs @@ -86,13 +86,18 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase get { return m_log; } } - public void InitializeEngine(Scene Sceneworld, LogBase logger, bool HookUpToServer, ScriptManager newScriptManager) + public void InitializeEngine(Scene Sceneworld, IConfigSource config, LogBase logger, bool HookUpToServer, ScriptManager newScriptManager) { World = Sceneworld; m_log = logger; - ScriptConfigSource = ConfigSource.Configs[ScriptEngineName]; + ConfigSource = config; + Log.Verbose(ScriptEngineName, "ScriptEngine initializing"); + Log.Verbose(ScriptEngineName, "Reading configuration from config section \"" + ScriptEngineName + "\""); - Log.Verbose(ScriptEngineName, "DotNet & LSL ScriptEngine initializing"); + // Make sure we have config + if (ConfigSource.Configs[ScriptEngineName] == null) + ConfigSource.AddConfig(ScriptEngineName); + ScriptConfigSource = ConfigSource.Configs[ScriptEngineName]; //m_logger.Status(ScriptEngineName, "InitializeEngine"); diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptServerInterfaces.cs b/OpenSim/Region/ScriptEngine/Common/ScriptServerInterfaces.cs index ac3e8b7504..38f7e7bdf9 100644 --- a/OpenSim/Region/ScriptEngine/Common/ScriptServerInterfaces.cs +++ b/OpenSim/Region/ScriptEngine/Common/ScriptServerInterfaces.cs @@ -27,6 +27,7 @@ */ using libsecondlife; +using Nini.Config; using OpenSim.Framework; using OpenSim.Framework.Console; using OpenSim.Region.Environment.Scenes; @@ -81,7 +82,7 @@ namespace OpenSim.Region.ScriptEngine.Common public interface ScriptEngine { RemoteEvents EventManager(); - void InitializeEngine(Scene Sceneworld, LogBase logger, bool DontHookUp, ScriptManager newScriptManager); + void InitializeEngine(Scene Sceneworld, IConfigSource config, LogBase logger, bool DontHookUp, ScriptManager newScriptManager); ScriptManager GetScriptManager(); } diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs index 5ba37f7eb5..720f946706 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs @@ -40,7 +40,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine public override void Initialise(Scene scene, IConfigSource config) { ConfigSource = config; - InitializeEngine(scene, MainLog.Instance, true, GetScriptManager()); + InitializeEngine(scene, config, MainLog.Instance, true, GetScriptManager()); } public override OpenSim.Region.ScriptEngine.Common.ScriptEngineBase.ScriptManager _GetScriptManager() diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs index 9cad388e0d..8030a32753 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs @@ -41,7 +41,6 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine : base(scriptEngine) { base.m_scriptEngine = scriptEngine; - } // KEEP TRACK OF SCRIPTS @@ -55,7 +54,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine public override void _StartScript(uint localID, LLUUID itemID, string Script) { //IScriptHost root = host.GetRoot(); - Console.WriteLine("ScriptManager StartScript: localID: " + localID + ", itemID: " + itemID); + m_scriptEngine.Log.Debug(m_scriptEngine.ScriptEngineName, "ScriptManager StartScript: localID: " + localID + ", itemID: " + itemID); // We will initialize and start the script. // It will be up to the script itself to hook up the correct events. @@ -77,7 +76,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine CompiledScript = m_scriptEngine.m_AppDomainManager.LoadScript(ScriptSource); #if DEBUG - Console.WriteLine("Script " + itemID + " occupies {0} bytes", GC.GetTotalMemory(true) - before); + m_scriptEngine.Log.Debug(m_scriptEngine.ScriptEngineName, "Script " + itemID + " occupies {0} bytes", GC.GetTotalMemory(true) - before); #endif CompiledScript.Source = Script; @@ -110,8 +109,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine } catch (Exception e2) { - m_scriptEngine.Log.Error("ScriptEngine", "Error displaying error in-world: " + e2.ToString()); - m_scriptEngine.Log.Error("ScriptEngine", + m_scriptEngine.Log.Error(m_scriptEngine.ScriptEngineName, "Error displaying error in-world: " + e2.ToString()); + m_scriptEngine.Log.Error(m_scriptEngine.ScriptEngineName, "Errormessage: Error compiling script:\r\n" + e.Message.ToString()); } } @@ -120,8 +119,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine public override void _StopScript(uint localID, LLUUID itemID) { // Stop script - Console.WriteLine("Stop script localID: " + localID + " LLUID: " + itemID.ToString()); - +#if DEBUG + m_scriptEngine.Log.Debug(m_scriptEngine.ScriptEngineName, "Stop script localID: " + localID + " LLUID: " + itemID.ToString()); +#endif // Stop long command on script m_scriptEngine.m_ASYNCLSLCommandManager.RemoveScript(localID, itemID); @@ -147,7 +147,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine } catch (Exception e) { - Console.WriteLine("Exception stopping script localID: " + localID + " LLUID: " + itemID.ToString() + + m_scriptEngine.Log.Error(m_scriptEngine.ScriptEngineName, "Exception stopping script localID: " + localID + " LLUID: " + itemID.ToString() + ": " + e.ToString()); } } diff --git a/OpenSim/Region/ScriptEngine/LSOEngine/ScriptEngine.cs b/OpenSim/Region/ScriptEngine/LSOEngine/ScriptEngine.cs index 49727c2314..45dfd9ef6e 100644 --- a/OpenSim/Region/ScriptEngine/LSOEngine/ScriptEngine.cs +++ b/OpenSim/Region/ScriptEngine/LSOEngine/ScriptEngine.cs @@ -44,7 +44,7 @@ namespace OpenSim.Region.ScriptEngine.LSOEngine // We need to override a few things for our DotNetEngine public override void Initialise(Scene scene, IConfigSource config) { - InitializeEngine(scene, MainLog.Instance, true, GetScriptManager()); + InitializeEngine(scene, config, MainLog.Instance, true, GetScriptManager()); } public override OpenSim.Region.ScriptEngine.Common.ScriptEngineBase.ScriptManager _GetScriptManager() diff --git a/prebuild.xml b/prebuild.xml index 22ab82e106..6e64ce4bf6 100644 --- a/prebuild.xml +++ b/prebuild.xml @@ -1280,6 +1280,7 @@ +