From 5e4d6cab00cb29cd088ab7b62ab13aff103b64cb Mon Sep 17 00:00:00 2001 From: onefang Date: Sun, 19 May 2019 21:24:15 +1000 Subject: Dump OpenSim 0.9.0.1 into it's own branch. --- OpenSim/Region/Application/Application.cs | 69 ++++---- OpenSim/Region/Application/ConfigurationLoader.cs | 24 ++- OpenSim/Region/Application/IApplicationPlugin.cs | 2 +- OpenSim/Region/Application/OpenSim.cs | 197 ++++++++++++++------- OpenSim/Region/Application/OpenSimBase.cs | 185 ++++++++++++++----- .../Region/Application/Properties/AssemblyInfo.cs | 10 +- .../Region/Application/RegionApplicationBase.cs | 38 ++-- 7 files changed, 356 insertions(+), 169 deletions(-) (limited to 'OpenSim/Region/Application') diff --git a/OpenSim/Region/Application/Application.cs b/OpenSim/Region/Application/Application.cs index bf34419..66ce8e5 100644 --- a/OpenSim/Region/Application/Application.cs +++ b/OpenSim/Region/Application/Application.cs @@ -74,7 +74,16 @@ namespace OpenSim AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); - ServicePointManager.DefaultConnectionLimit = 12; + if(Util.IsWindows()) + ServicePointManager.DefaultConnectionLimit = 32; + else + { + ServicePointManager.DefaultConnectionLimit = 12; + } + + try { ServicePointManager.DnsRefreshTimeout = 300000; } catch { } + ServicePointManager.Expect100Continue = false; + ServicePointManager.UseNagleAlgorithm = false; // Add the arguments supplied when running the application to the configuration ArgvConfigSource configSource = new ArgvConfigSource(args); @@ -85,9 +94,9 @@ namespace OpenSim if (logConfigFile != String.Empty) { XmlConfigurator.Configure(new System.IO.FileInfo(logConfigFile)); - m_log.InfoFormat("[OPENSIM MAIN]: configured log4net using \"{0}\" as configuration file", + m_log.InfoFormat("[OPENSIM MAIN]: configured log4net using \"{0}\" as configuration file", logConfigFile); - } + } else { XmlConfigurator.Configure(); @@ -103,22 +112,22 @@ namespace OpenSim "[OPENSIM MAIN]: Environment variable MONO_THREADS_PER_CPU is {0}", monoThreadsPerCpu ?? "unset"); // 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 + // .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 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", + "[OPENSIM MAIN]: Runtime gave us {0} min worker threads and {1} min IOCP threads", currentMinWorkerThreads, currentMinIocpThreads); } @@ -137,30 +146,30 @@ namespace OpenSim 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) + // 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 + // 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 + // set the resulting worker and IO completion thread counts back to ThreadPool if ( System.Threading.ThreadPool.SetMaxThreads(workerThreads, iocpThreads) ) - { - m_log.InfoFormat( + { + 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."); - } + } + 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 @@ -178,7 +187,7 @@ namespace OpenSim 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 + // If not, offer to do the most basic configuration for them warning them along the way of the importance of // reading these files. /* m_log.Info("Checking for reguired configuration...\n"); @@ -187,13 +196,13 @@ namespace OpenSim || (File.Exists(Path.Combine(Util.configDir(), "opensim.ini"))) || (File.Exists(Path.Combine(Util.configDir(), "openSim.ini"))) || (File.Exists(Path.Combine(Util.configDir(), "Opensim.ini"))); - + bool StanaloneCommon_ProperCased = File.Exists(Path.Combine(Path.Combine(Util.configDir(), "config-include"), "StandaloneCommon.ini")); bool StanaloneCommon_lowercased = File.Exists(Path.Combine(Path.Combine(Util.configDir(), "config-include"), "standalonecommon.ini")); bool GridCommon_ProperCased = File.Exists(Path.Combine(Path.Combine(Util.configDir(), "config-include"), "GridCommon.ini")); bool GridCommon_lowerCased = File.Exists(Path.Combine(Path.Combine(Util.configDir(), "config-include"), "gridcommon.ini")); - if ((OpenSim_Ini) + if ((OpenSim_Ini) && ( (StanaloneCommon_ProperCased || StanaloneCommon_lowercased @@ -211,7 +220,7 @@ namespace OpenSim "yes"); if (resp == "yes") { - + if (!(OpenSim_Ini)) { try @@ -311,7 +320,7 @@ namespace OpenSim m_saveCrashDumps = configSource.Configs["Startup"].GetBoolean("save_crashes", false); // load Crash directory config - m_crashDir = configSource.Configs["Startup"].GetString("crash_dir", m_crashDir); + m_crashDir = configSource.Configs["Startup"].GetString("crash_dir", m_crashDir); if (background) { @@ -319,9 +328,9 @@ namespace OpenSim m_sim.Startup(); } else - { + { m_sim = new OpenSim(configSource); - + m_sim.Startup(); while (true) diff --git a/OpenSim/Region/Application/ConfigurationLoader.cs b/OpenSim/Region/Application/ConfigurationLoader.cs index cf7db97..62bd4f4 100644 --- a/OpenSim/Region/Application/ConfigurationLoader.cs +++ b/OpenSim/Region/Application/ConfigurationLoader.cs @@ -43,10 +43,10 @@ namespace OpenSim public class ConfigurationLoader { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - + /// /// Various Config settings the region needs to start - /// Physics Engine, Mesh Engine, GridMode, PhysicsPrim allowed, Neighbor, + /// Physics Engine, Mesh Engine, GridMode, PhysicsPrim allowed, Neighbor, /// StorageDLL, Storage Connection String, Estate connection String, Client Stack /// Standalone settings. /// @@ -154,14 +154,15 @@ namespace OpenSim } // Override distro settings with contents of inidirectory - string iniDirPath = Path.GetFullPath(Path.Combine(Util.configDir(), startupConfig.GetString("inidirectory", "config"))); + string iniDirName = startupConfig.GetString("inidirectory", "config"); + string iniDirPath = Path.Combine(Util.configDir(), iniDirName); if (Directory.Exists(iniDirPath)) { m_log.InfoFormat("[CONFIG]: Searching folder {0} for config ini files", iniDirPath); List overrideSources = new List(); - string[] fileEntries = Directory.GetFiles(iniDirPath); + string[] fileEntries = Directory.GetFiles(iniDirName); foreach (string filePath in fileEntries) { if (Path.GetExtension(filePath).ToLower() == ".ini") @@ -187,7 +188,7 @@ namespace OpenSim { iniFileExists = true; AddIncludes(overrideConfig, overrideSources); - } + } } m_config.Source.Merge(overrideConfig.Source); } @@ -197,7 +198,7 @@ namespace OpenSim { m_log.FatalFormat("[CONFIG]: Could not load any configuration"); Environment.Exit(1); - } + } else if (!iniFileExists) { m_log.FatalFormat("[CONFIG]: Could not load any configuration"); @@ -256,14 +257,14 @@ namespace OpenSim string path = Path.Combine(basepath, chunkWithoutWildcards); path = Path.GetFullPath(path) + chunkWithWildcards; string[] paths = Util.Glob(path); - + // If the include path contains no wildcards, then warn the user that it wasn't found. if (wildcardIndex == -1 && paths.Length == 0) { m_log.WarnFormat("[CONFIG]: Could not find include file {0}", path); } else - { + { foreach (string p in paths) { if (!sources.Contains(p)) @@ -347,13 +348,10 @@ namespace OpenSim config.Set("meshing", "Meshmerizer"); config.Set("physical_prim", true); config.Set("serverside_object_permissions", true); - config.Set("storage_prim_inventories", true); config.Set("startup_console_commands_file", String.Empty); config.Set("shutdown_console_commands_file", String.Empty); config.Set("DefaultScriptEngine", "XEngine"); config.Set("clientstack_plugin", "OpenSim.Region.ClientStack.LindenUDP.dll"); - // life doesn't really work without this - config.Set("EventQueue", true); } { @@ -379,11 +377,11 @@ namespace OpenSim m_configSettings.PhysicsEngine = startupConfig.GetString("physics"); m_configSettings.MeshEngineName = startupConfig.GetString("meshing"); - m_configSettings.ClientstackDll + m_configSettings.ClientstackDll = startupConfig.GetString("clientstack_plugin", "OpenSim.Region.ClientStack.LindenUDP.dll"); } m_networkServersInfo.loadFromConfiguration(m_config.Source); } } -} \ No newline at end of file +} diff --git a/OpenSim/Region/Application/IApplicationPlugin.cs b/OpenSim/Region/Application/IApplicationPlugin.cs index a3fa66c..ff3f5d7 100644 --- a/OpenSim/Region/Application/IApplicationPlugin.cs +++ b/OpenSim/Region/Application/IApplicationPlugin.cs @@ -43,7 +43,7 @@ namespace OpenSim void Initialise(OpenSimBase openSim); /// - /// Called when the application loading is completed + /// Called when the application loading is completed /// void PostInitialise(); } diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs index 5af8194..fcc8717 100644 --- a/OpenSim/Region/Application/OpenSim.cs +++ b/OpenSim/Region/Application/OpenSim.cs @@ -26,12 +26,14 @@ */ using System; +using System.Threading; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; +using System.Runtime; using System.Text; using System.Text.RegularExpressions; using System.Timers; @@ -74,7 +76,7 @@ namespace OpenSim private string m_timedScript = "disabled"; private int m_timeInterval = 1200; - private Timer m_scriptTimer; + private System.Timers.Timer m_scriptTimer; public OpenSim(IConfigSource configSource) : base(configSource) { @@ -114,8 +116,8 @@ namespace OpenSim if (!String.IsNullOrEmpty(asyncCallMethodStr) && Utils.EnumTryParse(asyncCallMethodStr, out asyncCallMethod)) Util.FireAndForgetMethod = asyncCallMethod; - stpMinThreads = startupConfig.GetInt("MinPoolThreads", 15); - stpMaxThreads = startupConfig.GetInt("MaxPoolThreads", 300); + stpMinThreads = startupConfig.GetInt("MinPoolThreads", 2 ); + stpMaxThreads = startupConfig.GetInt("MaxPoolThreads", 25); m_consolePrompt = startupConfig.GetString("ConsolePrompt", @"Region (\R) "); } @@ -123,8 +125,27 @@ namespace OpenSim Util.InitThreadPool(stpMinThreads, stpMaxThreads); m_log.Info("[OPENSIM MAIN]: Using async_call_method " + Util.FireAndForgetMethod); + + m_log.InfoFormat("[OPENSIM MAIN] Running GC in {0} mode", GCSettings.IsServerGC ? "server":"workstation"); } +#if (_MONO) + private static Mono.Unix.UnixSignal[] signals; + + + private Thread signal_thread = new Thread (delegate () + { + while (true) + { + // Wait for a signal to be delivered + int index = Mono.Unix.UnixSignal.WaitAny (signals, -1); + + //Mono.Unix.Native.Signum signal = signals [index].Signum; + MainConsole.Instance.RunCommand("shutdown"); + } + }); +#endif + /// /// Performs initialisation of the scene, such as loading configuration from disk. /// @@ -134,6 +155,27 @@ namespace OpenSim m_log.Info("========================= STARTING OPENSIM ========================="); m_log.Info("===================================================================="); +#if (_MONO) + if(!Util.IsWindows()) + { + try + { + // linux mac os specifics + signals = new Mono.Unix.UnixSignal[] + { + new Mono.Unix.UnixSignal(Mono.Unix.Native.Signum.SIGTERM) + }; + signal_thread.IsBackground = true; + signal_thread.Start(); + } + catch (Exception e) + { + m_log.Info("Could not set up UNIX signal handlers. SIGTERM will not"); + m_log.InfoFormat("shut down gracefully: {0}", e.Message); + m_log.Debug("Exception was: ", e); + } + } +#endif //m_log.InfoFormat("[OPENSIM MAIN]: GC Is Server GC: {0}", GCSettings.IsServerGC.ToString()); // http://msdn.microsoft.com/en-us/library/bb384202.aspx //GCSettings.LatencyMode = GCLatencyMode.Batch; @@ -172,10 +214,12 @@ namespace OpenSim MainServer.Instance.AddStreamHandler(new OpenSim.XSimStatusHandler(this)); if (userStatsURI != String.Empty) MainServer.Instance.AddStreamHandler(new OpenSim.UXSimStatusHandler(this)); + MainServer.Instance.AddStreamHandler(new OpenSim.SimRobotsHandler()); if (managedStatsURI != String.Empty) { string urlBase = String.Format("/{0}/", managedStatsURI); + StatsManager.StatsPassword = managedStatsPassword; MainServer.Instance.AddHTTPHandler(urlBase, StatsManager.HandleStatsRequest); m_log.InfoFormat("[OPENSIM] Enabling remote managed stats fetch. URL = {0}", urlBase); } @@ -217,7 +261,7 @@ namespace OpenSim // Start timer script (run a script every xx seconds) if (m_timedScript != "disabled") { - m_scriptTimer = new Timer(); + m_scriptTimer = new System.Timers.Timer(); m_scriptTimer.Enabled = true; m_scriptTimer.Interval = m_timeInterval*1000; m_scriptTimer.Elapsed += RunAutoTimerScript; @@ -238,55 +282,65 @@ namespace OpenSim m_console.Commands.AddCommand("General", false, "change region", "change region ", - "Change current console region", + "Change current console region", ChangeSelectedRegion); m_console.Commands.AddCommand("Archiving", false, "save xml", - "save xml", - "Save a region's data in XML format", + "save xml []", + "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", + "save xml2 []", + "Save a region's data in XML2 format", SaveXml2); m_console.Commands.AddCommand("Archiving", false, "load xml", - "load xml [-newIDs [ ]]", + "load xml [ [-newUID [ ]]]", "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", + "load xml2 []", + "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", + "Save named prim to XML2", SavePrimsXml2); m_console.Commands.AddCommand("Archiving", false, "load oar", - "load oar [--merge] [--skip-assets]" + "load oar [-m|--merge] [-s|--skip-assets]" + " [--default-user \"User Name\"]" + " [--force-terrain] [--force-parcels]" + " [--no-objects]" - + " [--rotation degrees] [--rotation-center \"\"]" - + " [--displacement \"\"]" + + " [--rotation degrees]" + + " [--bounding-origin \"\"]" + + " [--bounding-size \"\"]" + + " [--displacement \"\"]" + + " [-d|--debug]" + " []", "Load a region's data from an OAR archive.", "--merge will merge the OAR with the existing scene (suppresses terrain and parcel info loading).\n" + + "--skip-assets will load the OAR but ignore the assets it contains.\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" + + "--bounding-origin will only place objects that after displacement and rotation fall within the bounding cube who's position starts at . Defaults to <0,0,0>.\n" + + "--bounding-size specifies the size of the bounding cube. The default is the size of the destination region and cannot be larger than this.\n" + + "--displacement will add this value to the position of every object loaded.\n" + + "--debug forces the archiver to display messages about where each object is being placed.\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); + + " If this is not given then the command looks for an OAR named region.oar in the current directory." + + " [--rotation-center \"\"] used to be an option, now it does nothing and will be removed soon." + + "When an OAR is being loaded, operations are applied in this order:\n" + + "1: Rotation (around the incoming OARs region center)\n" + + "2: Cropping (a bounding cube with origin and size)\n" + + "3: Displacement (setting offset coordinates within the destination region)", + LoadOar); ; m_console.Commands.AddCommand("Archiving", false, "save oar", //"save oar [-v|--version=] [-p|--profile=] []", @@ -307,12 +361,12 @@ namespace OpenSim m_console.Commands.AddCommand("Objects", false, "edit scale", "edit scale ", - "Change the scale of a named prim", + "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)", + "Rotates all scene objects around centerX, centerY (default 128, 128) (please back up your region before using)", HandleRotateScene); m_console.Commands.AddCommand("Objects", false, "scale scene", @@ -334,44 +388,44 @@ namespace OpenSim m_console.Commands.AddCommand("Users", false, "show users", "show users [full]", - "Show user data for users currently on the region", + "Show user data for users currently on the region", "Without the 'full' option, only users actually on the region are shown." + " With the 'full' option child agents of users in neighbouring regions are also shown.", HandleShow); m_console.Commands.AddCommand("Comms", false, "show connections", "show connections", - "Show connection data", + "Show connection data", HandleShow); m_console.Commands.AddCommand("Comms", false, "show circuits", "show circuits", - "Show agent circuit data", + "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", + "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", + "Show module data", HandleShow); m_console.Commands.AddCommand("Regions", false, "show regions", "show regions", - "Show region data", + "Show region data", HandleShow); - + m_console.Commands.AddCommand("Regions", false, "show ratings", "show ratings", - "Show rating data", + "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.", + "Persist currently unsaved object changes immediately instead of waiting for the normal persistence call.", RunCommand); m_console.Commands.AddCommand("Regions", false, "create region", @@ -385,22 +439,22 @@ namespace OpenSim m_console.Commands.AddCommand("Regions", false, "restart", "restart", - "Restart the currently selected region(s) in this instance", + "Restart the currently selected region(s) in this instance", RunCommand); m_console.Commands.AddCommand("General", false, "command-script", "command-script