From 134f86e8d5c414409631b25b8c6f0ee45fbd8631 Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Thu, 3 Nov 2016 21:44:39 +1000 Subject: Initial update to OpenSim 0.8.2.1 source code. --- OpenSim/Region/Application/Application.cs | 67 ++- OpenSim/Region/Application/ConfigurationLoader.cs | 98 ++-- OpenSim/Region/Application/IApplicationPlugin.cs | 2 + OpenSim/Region/Application/OpenSim.cs | 641 ++++++++++++++++----- OpenSim/Region/Application/OpenSimBackground.cs | 2 +- OpenSim/Region/Application/OpenSimBase.cs | 305 ++++------ .../Region/Application/Properties/AssemblyInfo.cs | 36 ++ .../Region/Application/RegionApplicationBase.cs | 103 ++++ 8 files changed, 868 insertions(+), 386 deletions(-) create mode 100644 OpenSim/Region/Application/Properties/AssemblyInfo.cs create mode 100644 OpenSim/Region/Application/RegionApplicationBase.cs (limited to 'OpenSim/Region/Application') diff --git a/OpenSim/Region/Application/Application.cs b/OpenSim/Region/Application/Application.cs index 0f90d37..bf34419 100644 --- a/OpenSim/Region/Application/Application.cs +++ b/OpenSim/Region/Application/Application.cs @@ -102,34 +102,81 @@ namespace OpenSim m_log.InfoFormat( "[OPENSIM MAIN]: Environment variable MONO_THREADS_PER_CPU is {0}", monoThreadsPerCpu ?? "unset"); - // Increase the number of IOCP threads available. Mono defaults to a tragically low number + // Verify the Threadpool allocates or uses enough worker and IO completion threads + // .NET 2.0, workerthreads default to 50 * numcores + // .NET 3.0, workerthreads defaults to 250 * numcores + // .NET 4.0, workerthreads are dynamic based on bitness and OS resources + // Max IO Completion threads are 1000 on all 3 CLRs + // + // Mono 2.10.9 to at least Mono 3.1, workerthreads default to 100 * numcores, iocp threads to 4 * numcores + int workerThreadsMin = 500; + int workerThreadsMax = 1000; // may need further adjustment to match other CLR + int iocpThreadsMin = 1000; + int iocpThreadsMax = 2000; // may need further adjustment to match other CLR + + { + int currentMinWorkerThreads, currentMinIocpThreads; + System.Threading.ThreadPool.GetMinThreads(out currentMinWorkerThreads, out currentMinIocpThreads); + m_log.InfoFormat( + "[OPENSIM MAIN]: Runtime gave us {0} min worker threads and {1} min IOCP threads", + currentMinWorkerThreads, currentMinIocpThreads); + } + int workerThreads, iocpThreads; System.Threading.ThreadPool.GetMaxThreads(out workerThreads, out iocpThreads); - m_log.InfoFormat("[OPENSIM MAIN]: Runtime gave us {0} worker threads and {1} IOCP threads", workerThreads, iocpThreads); - if (workerThreads < 500 || iocpThreads < 1000) + m_log.InfoFormat("[OPENSIM MAIN]: Runtime gave us {0} max worker threads and {1} max IOCP threads", workerThreads, iocpThreads); + + if (workerThreads < workerThreadsMin) + { + workerThreads = workerThreadsMin; + m_log.InfoFormat("[OPENSIM MAIN]: Bumping up max worker threads to {0}",workerThreads); + } + if (workerThreads > workerThreadsMax) { - workerThreads = 500; - iocpThreads = 1000; - m_log.Info("[OPENSIM MAIN]: Bumping up to 500 worker threads and 1000 IOCP threads"); - System.Threading.ThreadPool.SetMaxThreads(workerThreads, iocpThreads); + workerThreads = workerThreadsMax; + m_log.InfoFormat("[OPENSIM MAIN]: Limiting max worker threads to {0}",workerThreads); } + // Increase the number of IOCP threads available. + // Mono defaults to a tragically low number (24 on 6-core / 8GB Fedora 17) + if (iocpThreads < iocpThreadsMin) + { + iocpThreads = iocpThreadsMin; + m_log.InfoFormat("[OPENSIM MAIN]: Bumping up max IOCP threads to {0}",iocpThreads); + } + // Make sure we don't overallocate IOCP threads and thrash system resources + if ( iocpThreads > iocpThreadsMax ) + { + iocpThreads = iocpThreadsMax; + m_log.InfoFormat("[OPENSIM MAIN]: Limiting max IOCP completion threads to {0}",iocpThreads); + } + // set the resulting worker and IO completion thread counts back to ThreadPool + if ( System.Threading.ThreadPool.SetMaxThreads(workerThreads, iocpThreads) ) + { + m_log.InfoFormat( + "[OPENSIM MAIN]: Threadpool set to {0} max worker threads and {1} max IOCP threads", + workerThreads, iocpThreads); + } + else + { + m_log.Warn("[OPENSIM MAIN]: Threadpool reconfiguration failed, runtime defaults still in effect."); + } + // Check if the system is compatible with OpenSimulator. // Ensures that the minimum system requirements are met string supported = String.Empty; if (Util.IsEnvironmentSupported(ref supported)) { - m_log.Info("Environment is compatible.\n"); + m_log.Info("[OPENSIM MAIN]: Environment is supported by OpenSimulator."); } else { - m_log.Warn("Environment is unsupported (" + supported + ")\n"); + m_log.Warn("[OPENSIM MAIN]: Environment is not supported by OpenSimulator (" + supported + ")\n"); } // Configure nIni aliases and localles Culture.SetCurrentCulture(); - // Validate that the user has the most basic configuration done // If not, offer to do the most basic configuration for them warning them along the way of the importance of // reading these files. diff --git a/OpenSim/Region/Application/ConfigurationLoader.cs b/OpenSim/Region/Application/ConfigurationLoader.cs index fc3999f..b19e549 100644 --- a/OpenSim/Region/Application/ConfigurationLoader.cs +++ b/OpenSim/Region/Application/ConfigurationLoader.cs @@ -82,8 +82,7 @@ namespace OpenSim List sources = new List(); - string masterFileName = - startupConfig.GetString("inimaster", "OpenSimDefaults.ini"); + string masterFileName = startupConfig.GetString("inimaster", "OpenSimDefaults.ini"); if (masterFileName == "none") masterFileName = String.Empty; @@ -124,7 +123,7 @@ namespace OpenSim else { Application.iniFilePath = Path.GetFullPath( - Path.Combine(Util.configDir(), iniFileName)); + Path.Combine(Util.configDir(), iniFileName)); if (!File.Exists(Application.iniFilePath)) { @@ -139,12 +138,29 @@ namespace OpenSim } } + m_config = new OpenSimConfigSource(); + m_config.Source = new IniConfigSource(); + m_config.Source.Merge(DefaultConfig()); + + m_log.Info("[CONFIG]: Reading configuration settings"); + + for (int i = 0 ; i < sources.Count ; i++) + { + if (ReadConfig(m_config, sources[i])) + { + iniFileExists = true; + AddIncludes(m_config, sources); + } + } + + // Override distro settings with contents of inidirectory string iniDirName = startupConfig.GetString("inidirectory", "config"); string iniDirPath = Path.Combine(Util.configDir(), iniDirName); if (Directory.Exists(iniDirPath)) { - m_log.InfoFormat("Searching folder {0} for config ini files", iniDirPath); + m_log.InfoFormat("[CONFIG]: Searching folder {0} for config ini files", iniDirPath); + List overrideSources = new List(); string[] fileEntries = Directory.GetFiles(iniDirName); foreach (string filePath in fileEntries) @@ -152,58 +168,52 @@ namespace OpenSim if (Path.GetExtension(filePath).ToLower() == ".ini") { if (!sources.Contains(Path.GetFullPath(filePath))) + { + overrideSources.Add(Path.GetFullPath(filePath)); + // put it in sources too, to avoid circularity sources.Add(Path.GetFullPath(filePath)); + } } } - } - m_config = new OpenSimConfigSource(); - m_config.Source = new IniConfigSource(); - m_config.Source.Merge(DefaultConfig()); - m_log.Info("[CONFIG]: Reading configuration settings"); + if (overrideSources.Count > 0) + { + OpenSimConfigSource overrideConfig = new OpenSimConfigSource(); + overrideConfig.Source = new IniConfigSource(); + + for (int i = 0 ; i < overrideSources.Count ; i++) + { + if (ReadConfig(overrideConfig, overrideSources[i])) + { + iniFileExists = true; + AddIncludes(overrideConfig, overrideSources); + } + } + m_config.Source.Merge(overrideConfig.Source); + } + } if (sources.Count == 0) { m_log.FatalFormat("[CONFIG]: Could not load any configuration"); Environment.Exit(1); - } - - for (int i = 0 ; i < sources.Count ; i++) - { - if (ReadConfig(sources[i])) - { - iniFileExists = true; - AddIncludes(sources); - } - } - - if (!iniFileExists) + } + else if (!iniFileExists) { m_log.FatalFormat("[CONFIG]: Could not load any configuration"); m_log.FatalFormat("[CONFIG]: Configuration exists, but there was an error loading it!"); Environment.Exit(1); } + // Merge OpSys env vars + m_log.Info("[CONFIG]: Loading environment variables for Config"); + Util.MergeEnvironmentToConfig(m_config.Source); + // Make sure command line options take precedence m_config.Source.Merge(argvSource); - IConfig enVars = m_config.Source.Configs["Environment"]; - - if( enVars != null ) - { - string[] env_keys = enVars.GetKeys(); - - foreach ( string key in env_keys ) - { - envConfigSource.AddEnv(key, string.Empty); - } - - envConfigSource.LoadEnv(); - m_config.Source.Merge(envConfigSource); - m_config.Source.ExpandKeyValues(); - } - + m_config.Source.ReplaceKeyValues(); ReadConfigSettings(); @@ -214,10 +224,10 @@ namespace OpenSim /// Adds the included files as ini configuration files /// /// List of URL strings or filename strings - private void AddIncludes(List sources) + private void AddIncludes(OpenSimConfigSource configSource, List sources) { //loop over config sources - foreach (IConfig config in m_config.Source.Configs) + foreach (IConfig config in configSource.Source.Configs) { // Look for Include-* in the key name string[] keys = config.GetKeys(); @@ -284,7 +294,7 @@ namespace OpenSim /// /// Full path to the ini /// - private bool ReadConfig(string iniPath) + private bool ReadConfig(OpenSimConfigSource configSource, string iniPath) { bool success = false; @@ -292,7 +302,7 @@ namespace OpenSim { m_log.InfoFormat("[CONFIG]: Reading configuration file {0}", Path.GetFullPath(iniPath)); - m_config.Source.Merge(new IniConfigSource(iniPath)); + configSource.Source.Merge(new IniConfigSource(iniPath)); success = true; } else @@ -305,7 +315,7 @@ namespace OpenSim { XmlReader r = XmlReader.Create(iniPath); XmlConfigSource cs = new XmlConfigSource(r); - m_config.Source.Merge(cs); + configSource.Source.Merge(cs); success = true; } @@ -337,10 +347,7 @@ namespace OpenSim config.Set("physics", "OpenDynamicsEngine"); config.Set("meshing", "Meshmerizer"); config.Set("physical_prim", true); - config.Set("see_into_this_sim_from_neighbor", true); config.Set("serverside_object_permissions", true); - config.Set("storage_plugin", "OpenSim.Data.SQLite.dll"); - config.Set("storage_connection_string", "URI=file:OpenSim.db,version=3"); config.Set("storage_prim_inventories", true); config.Set("startup_console_commands_file", String.Empty); config.Set("shutdown_console_commands_file", String.Empty); @@ -372,7 +379,6 @@ namespace OpenSim { m_configSettings.PhysicsEngine = startupConfig.GetString("physics"); m_configSettings.MeshEngineName = startupConfig.GetString("meshing"); - m_configSettings.StorageDll = startupConfig.GetString("storage_plugin"); m_configSettings.ClientstackDll = startupConfig.GetString("clientstack_plugin", "OpenSim.Region.ClientStack.LindenUDP.dll"); diff --git a/OpenSim/Region/Application/IApplicationPlugin.cs b/OpenSim/Region/Application/IApplicationPlugin.cs index 6e6d48c..a3fa66c 100644 --- a/OpenSim/Region/Application/IApplicationPlugin.cs +++ b/OpenSim/Region/Application/IApplicationPlugin.cs @@ -26,12 +26,14 @@ */ using OpenSim.Framework; +using Mono.Addins; namespace OpenSim { /// /// OpenSimulator Application Plugin framework interface /// + [TypeExtensionPoint(NodeName="Plugin", NodeType = typeof(PluginExtensionNode), Path="/OpenSim/Startup")] public interface IApplicationPlugin : IPlugin { /// diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs index c4731a3..5af8194 100644 --- a/OpenSim/Region/Application/OpenSim.cs +++ b/OpenSim/Region/Application/OpenSim.cs @@ -30,6 +30,7 @@ using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; +using System.Linq; using System.Reflection; using System.Text; using System.Text.RegularExpressions; @@ -44,6 +45,7 @@ using OpenSim.Framework.Servers; using OpenSim.Framework.Monitoring; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; +using OpenSim.Services.Interfaces; namespace OpenSim { @@ -85,6 +87,7 @@ namespace OpenSim IConfig startupConfig = Config.Configs["Startup"]; IConfig networkConfig = Config.Configs["Network"]; + int stpMinThreads = 2; int stpMaxThreads = 15; if (startupConfig != null) @@ -111,12 +114,13 @@ namespace OpenSim if (!String.IsNullOrEmpty(asyncCallMethodStr) && Utils.EnumTryParse(asyncCallMethodStr, out asyncCallMethod)) Util.FireAndForgetMethod = asyncCallMethod; - stpMaxThreads = startupConfig.GetInt("MaxPoolThreads", 15); + stpMinThreads = startupConfig.GetInt("MinPoolThreads", 15); + stpMaxThreads = startupConfig.GetInt("MaxPoolThreads", 300); m_consolePrompt = startupConfig.GetString("ConsolePrompt", @"Region (\R) "); } if (Util.FireAndForgetMethod == FireAndForgetMethod.SmartThreadPool) - Util.InitThreadPool(stpMaxThreads); + Util.InitThreadPool(stpMinThreads, stpMaxThreads); m_log.Info("[OPENSIM MAIN]: Using async_call_method " + Util.FireAndForgetMethod); } @@ -151,13 +155,14 @@ namespace OpenSim ((RemoteConsole)m_console).ReadConfig(Config); break; default: - m_console = new LocalConsole("Region"); + m_console = new LocalConsole("Region", Config.Configs["Startup"]); break; } } MainConsole.Instance = m_console; + LogEnvironmentInformation(); RegisterCommonAppenders(Config.Configs["Startup"]); RegisterConsoleCommands(); @@ -168,6 +173,13 @@ namespace OpenSim if (userStatsURI != String.Empty) MainServer.Instance.AddStreamHandler(new OpenSim.UXSimStatusHandler(this)); + if (managedStatsURI != String.Empty) + { + string urlBase = String.Format("/{0}/", managedStatsURI); + MainServer.Instance.AddHTTPHandler(urlBase, StatsManager.HandleStatsRequest); + m_log.InfoFormat("[OPENSIM] Enabling remote managed stats fetch. URL = {0}", urlBase); + } + if (m_console is RemoteConsole) { if (m_consolePort == 0) @@ -224,49 +236,56 @@ namespace OpenSim "Force the update of all objects on clients", HandleForceUpdate); - m_console.Commands.AddCommand("Debug", false, "debug packet", - "debug packet [ ]", - "Turn on packet debugging", - "If level > 255 then all incoming and outgoing packets are logged.\n" - + "If level <= 255 then incoming AgentUpdate and outgoing SimStats and SimulatorViewerTimeMessage packets are not logged.\n" - + "If level <= 200 then incoming RequestImage and outgoing ImagePacket, ImageData, LayerData and CoarseLocationUpdate packets are not logged.\n" - + "If level <= 100 then incoming ViewerEffect and AgentAnimation and outgoing ViewerEffect and AvatarAnimation packets are not logged.\n" - + "If level <= 50 then outgoing ImprovedTerseObjectUpdate packets are not logged.\n" - + "If level <= 0 then no packets are logged.\n" - + "If an avatar name is given then only packets from that avatar are logged", - Debug); - m_console.Commands.AddCommand("General", false, "change region", "change region ", - "Change current console region", ChangeSelectedRegion); + "Change current console region", + ChangeSelectedRegion); m_console.Commands.AddCommand("Archiving", false, "save xml", "save xml", - "Save a region's data in XML format", SaveXml); + "Save a region's data in XML format", + SaveXml); m_console.Commands.AddCommand("Archiving", false, "save xml2", "save xml2", - "Save a region's data in XML2 format", SaveXml2); + "Save a region's data in XML2 format", + SaveXml2); m_console.Commands.AddCommand("Archiving", false, "load xml", "load xml [-newIDs [ ]]", - "Load a region's data from XML format", LoadXml); + "Load a region's data from XML format", + LoadXml); m_console.Commands.AddCommand("Archiving", false, "load xml2", "load xml2", - "Load a region's data from XML2 format", LoadXml2); + "Load a region's data from XML2 format", + LoadXml2); m_console.Commands.AddCommand("Archiving", false, "save prims xml2", "save prims xml2 [ ]", - "Save named prim to XML2", SavePrimsXml2); + "Save named prim to XML2", + SavePrimsXml2); m_console.Commands.AddCommand("Archiving", false, "load oar", - "load oar [--merge] [--skip-assets] []", + "load oar [--merge] [--skip-assets]" + + " [--default-user \"User Name\"]" + + " [--force-terrain] [--force-parcels]" + + " [--no-objects]" + + " [--rotation degrees] [--rotation-center \"\"]" + + " [--displacement \"\"]" + + " []", "Load a region's data from an OAR archive.", - "--merge will merge the OAR with the existing scene." + Environment.NewLine - + "--skip-assets will load the OAR but ignore the assets it contains." + Environment.NewLine - + "The path can be either a filesystem location or a URI." - + " If this is not given then the command looks for an OAR named region.oar in the current directory.", + "--merge will merge the OAR with the existing scene (suppresses terrain and parcel info loading).\n" + + "--default-user will use this user for any objects with an owner whose UUID is not found in the grid.\n" + + "--displacement will add this value to the position of every object loaded.\n" + + "--force-terrain forces the loading of terrain from the oar (undoes suppression done by --merge).\n" + + "--force-parcels forces the loading of parcels from the oar (undoes suppression done by --merge).\n" + + "--no-objects suppresses the addition of any objects (good for loading only the terrain).\n" + + "--rotation specified rotation to be applied to the oar. Specified in degrees.\n" + + "--rotation-center Location (relative to original OAR) to apply rotation. Default is <128,128,0>.\n" + + "--skip-assets will load the OAR but ignore the assets it contains.\n\n" + + "The path can be either a filesystem location or a URI.\n" + + " If this is not given then the command looks for an OAR named region.oar in the current directory.", LoadOar); m_console.Commands.AddCommand("Archiving", false, "save oar", @@ -288,7 +307,23 @@ namespace OpenSim m_console.Commands.AddCommand("Objects", false, "edit scale", "edit scale ", - "Change the scale of a named prim", HandleEditScale); + "Change the scale of a named prim", + HandleEditScale); + + m_console.Commands.AddCommand("Objects", false, "rotate scene", + "rotate scene [centerX, centerY]", + "Rotates all scene objects around centerX, centerY (defailt 128, 128) (please back up your region before using)", + HandleRotateScene); + + m_console.Commands.AddCommand("Objects", false, "scale scene", + "scale scene ", + "Scales the scene objects (please back up your region before using)", + HandleScaleScene); + + m_console.Commands.AddCommand("Objects", false, "translate scene", + "translate scene xOffset yOffset zOffset", + "translates the scene objects (please back up your region before using)", + HandleTranslateScene); m_console.Commands.AddCommand("Users", false, "kick user", "kick user [--force] [message]", @@ -306,31 +341,38 @@ namespace OpenSim m_console.Commands.AddCommand("Comms", false, "show connections", "show connections", - "Show connection data", HandleShow); + "Show connection data", + HandleShow); m_console.Commands.AddCommand("Comms", false, "show circuits", "show circuits", - "Show agent circuit data", HandleShow); + "Show agent circuit data", + HandleShow); m_console.Commands.AddCommand("Comms", false, "show pending-objects", "show pending-objects", - "Show # of objects on the pending queues of all scene viewers", HandleShow); + "Show # of objects on the pending queues of all scene viewers", + HandleShow); m_console.Commands.AddCommand("General", false, "show modules", "show modules", - "Show module data", HandleShow); + "Show module data", + HandleShow); m_console.Commands.AddCommand("Regions", false, "show regions", "show regions", - "Show region data", HandleShow); + "Show region data", + HandleShow); m_console.Commands.AddCommand("Regions", false, "show ratings", "show ratings", - "Show rating data", HandleShow); + "Show rating data", + HandleShow); m_console.Commands.AddCommand("Objects", false, "backup", "backup", - "Persist currently unsaved object changes immediately instead of waiting for the normal persistence call.", RunCommand); + "Persist currently unsaved object changes immediately instead of waiting for the normal persistence call.", + RunCommand); m_console.Commands.AddCommand("Regions", false, "create region", "create region [\"region name\"] ", @@ -343,34 +385,47 @@ namespace OpenSim m_console.Commands.AddCommand("Regions", false, "restart", "restart", - "Restart all sims in this instance", RunCommand); + "Restart the currently selected region(s) in this instance", + RunCommand); m_console.Commands.AddCommand("General", false, "command-script", "command-script