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/OpenSimBase.cs | 305 ++++++++++++------------------
1 file changed, 119 insertions(+), 186 deletions(-)
(limited to 'OpenSim/Region/Application/OpenSimBase.cs')
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs
index c3c87e7..ab6f036 100644
--- a/OpenSim/Region/Application/OpenSimBase.cs
+++ b/OpenSim/Region/Application/OpenSimBase.cs
@@ -36,17 +36,15 @@ using log4net;
using Nini.Config;
using OpenMetaverse;
using OpenSim.Framework;
-using OpenSim.Framework.Communications;
using OpenSim.Framework.Console;
using OpenSim.Framework.Servers;
using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Framework.Monitoring;
-using OpenSim.Region.ClientStack;
using OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts;
using OpenSim.Region.Framework;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
-using OpenSim.Region.Physics.Manager;
+using OpenSim.Region.PhysicsModules.SharedBase;
using OpenSim.Server.Base;
using OpenSim.Services.Base;
using OpenSim.Services.Interfaces;
@@ -71,10 +69,25 @@ namespace OpenSim
// OpenSim.ini Section name for ESTATES Settings
public const string ESTATE_SECTION_NAME = "Estates";
+ ///
+ /// Allow all plugin loading to be disabled for tests/debug.
+ ///
+ ///
+ /// true by default
+ ///
+ public bool EnableInitialPluginLoad { get; set; }
+
+ ///
+ /// Control whether we attempt to load an estate data service.
+ ///
+ /// For tests/debugging
+ public bool LoadEstateDataService { get; set; }
+
protected string proxyUrl;
protected int proxyOffset = 0;
public string userStatsURI = String.Empty;
+ public string managedStatsURI = String.Empty;
protected bool m_autoCreateClientStack = true;
@@ -95,26 +108,19 @@ namespace OpenSim
public ConsoleCommand CreateAccount = null;
- protected List m_plugins = new List();
+ public List m_plugins = new List();
///
/// The config information passed into the OpenSimulator region server.
///
public OpenSimConfigSource ConfigSource { get; private set; }
- public List ClientServers
- {
- get { return m_clientServers; }
- }
-
protected EnvConfigSource m_EnvConfigSource = new EnvConfigSource();
public EnvConfigSource envConfigSource
{
get { return m_EnvConfigSource; }
}
-
- protected List m_clientServers = new List();
public uint HttpServerPort
{
@@ -134,6 +140,8 @@ namespace OpenSim
///
public OpenSimBase(IConfigSource configSource) : base()
{
+ EnableInitialPluginLoad = true;
+ LoadEstateDataService = true;
LoadConfigSettings(configSource);
}
@@ -153,14 +161,37 @@ namespace OpenSim
proxyUrl = networkConfig.GetString("proxy_url", "");
proxyOffset = Int32.Parse(networkConfig.GetString("proxy_offset", "0"));
}
+
+ IConfig startupConfig = Config.Configs["Startup"];
+ if (startupConfig != null)
+ {
+ Util.LogOverloads = startupConfig.GetBoolean("LogOverloads", true);
+ }
}
protected virtual void LoadPlugins()
{
- using (PluginLoader loader = new PluginLoader(new ApplicationPluginInitialiser(this)))
+ IConfig startupConfig = Config.Configs["Startup"];
+ string registryLocation = (startupConfig != null) ? startupConfig.GetString("RegistryLocation", String.Empty) : String.Empty;
+
+ // The location can also be specified in the environment. If there
+ // is no location in the configuration, we must call the constructor
+ // without a location parameter to allow that to happen.
+ if (registryLocation == String.Empty)
{
- loader.Load("/OpenSim/Startup");
- m_plugins = loader.Plugins;
+ using (PluginLoader loader = new PluginLoader(new ApplicationPluginInitialiser(this)))
+ {
+ loader.Load("/OpenSim/Startup");
+ m_plugins = loader.Plugins;
+ }
+ }
+ else
+ {
+ using (PluginLoader loader = new PluginLoader(new ApplicationPluginInitialiser(this), registryLocation))
+ {
+ loader.Load("/OpenSim/Startup");
+ m_plugins = loader.Plugins;
+ }
}
}
@@ -188,6 +219,7 @@ namespace OpenSim
CreatePIDFile(pidFile);
userStatsURI = startupConfig.GetString("Stats_URI", String.Empty);
+ managedStatsURI = startupConfig.GetString("ManagedStatsRemoteFetchURI", String.Empty);
}
// Load the simulation data service
@@ -207,34 +239,32 @@ namespace OpenSim
module));
// Load the estate data service
- IConfig estateDataConfig = Config.Configs["EstateDataStore"];
- if (estateDataConfig == null)
- throw new Exception("Configuration file is missing the [EstateDataStore] section. Have you copied OpenSim.ini.example to OpenSim.ini to reference config-include/ files?");
-
- module = estateDataConfig.GetString("LocalServiceModule", String.Empty);
+ module = Util.GetConfigVarFromSections(Config, "LocalServiceModule", new string[]{"EstateDataStore", "EstateService"}, String.Empty);
if (String.IsNullOrEmpty(module))
- throw new Exception("Configuration file is missing the LocalServiceModule parameter in the [EstateDataStore] section");
+ throw new Exception("Configuration file is missing the LocalServiceModule parameter in the [EstateDataStore] or [EstateService] section");
- m_estateDataService = ServerUtils.LoadPlugin(module, new object[] { Config });
- if (m_estateDataService == null)
- throw new Exception(
- string.Format(
- "Could not load an IEstateDataService implementation from {0}, as configured in the LocalServiceModule parameter of the [EstateDataStore] config section.",
- module));
+ if (LoadEstateDataService)
+ {
+ m_estateDataService = ServerUtils.LoadPlugin(module, new object[] { Config });
+ if (m_estateDataService == null)
+ throw new Exception(
+ string.Format(
+ "Could not load an IEstateDataService implementation from {0}, as configured in the LocalServiceModule parameter of the [EstateDataStore] config section.",
+ module));
+ }
base.StartupSpecific();
- LoadPlugins();
+ if (EnableInitialPluginLoad)
+ LoadPlugins();
+
+ // We still want to post initalize any plugins even if loading has been disabled since a test may have
+ // inserted them manually.
foreach (IApplicationPlugin plugin in m_plugins)
- {
plugin.PostInitialise();
- }
if (m_console != null)
- {
- StatsManager.RegisterConsoleCommands(m_console);
AddPluginCommands(m_console);
- }
}
protected virtual void AddPluginCommands(ICommandConsole console)
@@ -298,6 +328,10 @@ namespace OpenSim
{
// Called from base.StartUp()
+ IConfig startupConfig = Config.Configs["Startup"];
+ if (startupConfig == null || startupConfig.GetBoolean("JobEngineEnabled", true))
+ WorkManager.JobEngine.Start();
+
m_httpServerPort = m_networkServersInfo.HttpListenerPort;
SceneManager.OnRestartSim += HandleRestartRegion;
@@ -316,9 +350,9 @@ namespace OpenSim
///
///
///
- public IClientNetworkServer CreateRegion(RegionInfo regionInfo, bool portadd_flag, out IScene scene)
+ public void CreateRegion(RegionInfo regionInfo, bool portadd_flag, out IScene scene)
{
- return CreateRegion(regionInfo, portadd_flag, false, out scene);
+ CreateRegion(regionInfo, portadd_flag, false, out scene);
}
///
@@ -326,9 +360,9 @@ namespace OpenSim
///
///
///
- public IClientNetworkServer CreateRegion(RegionInfo regionInfo, out IScene scene)
+ public void CreateRegion(RegionInfo regionInfo, out IScene scene)
{
- return CreateRegion(regionInfo, false, true, out scene);
+ CreateRegion(regionInfo, false, true, out scene);
}
///
@@ -338,7 +372,7 @@ namespace OpenSim
///
///
///
- public IClientNetworkServer CreateRegion(RegionInfo regionInfo, bool portadd_flag, bool do_post_init, out IScene mscene)
+ public void CreateRegion(RegionInfo regionInfo, bool portadd_flag, bool do_post_init, out IScene mscene)
{
int port = regionInfo.InternalEndPoint.Port;
@@ -363,8 +397,7 @@ namespace OpenSim
Util.XmlRpcCommand(proxyUrl, "AddPort", port, port + proxyOffset, regionInfo.ExternalHostName);
}
- IClientNetworkServer clientServer;
- Scene scene = SetupScene(regionInfo, proxyOffset, Config, out clientServer);
+ Scene scene = SetupScene(regionInfo, proxyOffset, Config);
m_log.Info("[MODULES]: Loading Region's modules (old style)");
@@ -412,20 +445,20 @@ namespace OpenSim
SceneManager.Add(scene);
- if (m_autoCreateClientStack)
- {
- m_clientServers.Add(clientServer);
- clientServer.Start();
- }
+ //if (m_autoCreateClientStack)
+ //{
+ // foreach (IClientNetworkServer clientserver in clientServers)
+ // {
+ // m_clientServers.Add(clientserver);
+ // clientserver.Start();
+ // }
+ //}
scene.EventManager.OnShutdown += delegate() { ShutdownRegion(scene); };
mscene = scene;
- scene.Start();
- scene.StartScripts();
-
- return clientServer;
+ //return clientServers;
}
///
@@ -533,7 +566,7 @@ namespace OpenSim
else
{
regionInfo.EstateSettings.EstateOwner = account.PrincipalID;
- regionInfo.EstateSettings.Save();
+ m_estateDataService.StoreEstateSettings(regionInfo.EstateSettings);
}
}
@@ -559,7 +592,7 @@ namespace OpenSim
scene.DeleteAllSceneObjects();
SceneManager.CloseScene(scene);
- ShutdownClientServer(scene.RegionInfo);
+ //ShutdownClientServer(scene.RegionInfo);
if (!cleanup)
return;
@@ -620,7 +653,7 @@ namespace OpenSim
}
SceneManager.CloseScene(scene);
- ShutdownClientServer(scene.RegionInfo);
+ //ShutdownClientServer(scene.RegionInfo);
}
///
@@ -641,9 +674,9 @@ namespace OpenSim
///
///
///
- protected Scene SetupScene(RegionInfo regionInfo, out IClientNetworkServer clientServer)
+ protected Scene SetupScene(RegionInfo regionInfo)
{
- return SetupScene(regionInfo, 0, null, out clientServer);
+ return SetupScene(regionInfo, 0, null);
}
///
@@ -654,176 +687,87 @@ namespace OpenSim
///
///
///
- protected Scene SetupScene(
- RegionInfo regionInfo, int proxyOffset, IConfigSource configSource, out IClientNetworkServer clientServer)
+ protected Scene SetupScene(RegionInfo regionInfo, int proxyOffset, IConfigSource configSource)
{
- AgentCircuitManager circuitManager = new AgentCircuitManager();
- IPAddress listenIP = regionInfo.InternalEndPoint.Address;
- //if (!IPAddress.TryParse(regionInfo.InternalEndPoint, out listenIP))
- // listenIP = IPAddress.Parse("0.0.0.0");
-
- uint port = (uint) regionInfo.InternalEndPoint.Port;
-
- if (m_autoCreateClientStack)
- {
- clientServer
- = m_clientStackManager.CreateServer(
- listenIP, ref port, proxyOffset, regionInfo.m_allow_alternate_ports, configSource,
- circuitManager);
- }
- else
- {
- clientServer = null;
- }
-
- regionInfo.InternalEndPoint.Port = (int) port;
+ //List clientNetworkServers = null;
+ AgentCircuitManager circuitManager = new AgentCircuitManager();
Scene scene = CreateScene(regionInfo, m_simulationDataService, m_estateDataService, circuitManager);
- if (m_autoCreateClientStack)
- {
- clientServer.AddScene(scene);
- }
-
scene.LoadWorldMap();
- scene.PhysicsScene = GetPhysicsScene(scene.RegionInfo.RegionName);
- scene.PhysicsScene.RequestAssetMethod = scene.PhysicsRequestAsset;
- scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised());
- scene.PhysicsScene.SetWaterLevel((float) regionInfo.RegionSettings.WaterHeight);
-
return scene;
}
- protected override ClientStackManager CreateClientStackManager()
- {
- return new ClientStackManager(m_configSettings.ClientstackDll);
- }
-
protected override Scene CreateScene(RegionInfo regionInfo, ISimulationDataService simDataService,
IEstateDataService estateDataService, AgentCircuitManager circuitManager)
{
- SceneCommunicationService sceneGridService = new SceneCommunicationService();
-
return new Scene(
- regionInfo, circuitManager, sceneGridService,
- simDataService, estateDataService, false,
+ regionInfo, circuitManager,
+ simDataService, estateDataService,
Config, m_version);
}
- protected void ShutdownClientServer(RegionInfo whichRegion)
- {
- // Close and remove the clientserver for a region
- bool foundClientServer = false;
- int clientServerElement = 0;
- Location location = new Location(whichRegion.RegionHandle);
-
- for (int i = 0; i < m_clientServers.Count; i++)
- {
- if (m_clientServers[i].HandlesRegion(location))
- {
- clientServerElement = i;
- foundClientServer = true;
- break;
- }
- }
-
- if (foundClientServer)
- {
- m_clientServers[clientServerElement].NetworkStop();
- m_clientServers.RemoveAt(clientServerElement);
- }
- }
-
protected virtual void HandleRestartRegion(RegionInfo whichRegion)
{
m_log.InfoFormat(
"[OPENSIM]: Got restart signal from SceneManager for region {0} ({1},{2})",
whichRegion.RegionName, whichRegion.RegionLocX, whichRegion.RegionLocY);
- ShutdownClientServer(whichRegion);
+ //ShutdownClientServer(whichRegion);
IScene scene;
CreateRegion(whichRegion, true, out scene);
+ scene.Start();
}
# region Setup methods
- protected override PhysicsScene GetPhysicsScene(string osSceneIdentifier)
- {
- return GetPhysicsScene(
- m_configSettings.PhysicsEngine, m_configSettings.MeshEngineName, Config, osSceneIdentifier);
- }
-
///
/// Handler to supply the current status of this sim
///
+ ///
/// Currently this is always OK if the simulator is still listening for connections on its HTTP service
- public class SimStatusHandler : IStreamedRequestHandler
+ ///
+ public class SimStatusHandler : BaseStreamHandler
{
- public byte[] Handle(string path, Stream request,
+ public SimStatusHandler() : base("GET", "/simstatus", "SimStatus", "Simulator Status") {}
+
+ protected override byte[] ProcessRequest(string path, Stream request,
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{
return Util.UTF8.GetBytes("OK");
}
- public string Name { get { return "SimStatus"; } }
- public string Description { get { return "Simulator Status"; } }
-
- public string ContentType
+ public override string ContentType
{
get { return "text/plain"; }
}
-
- public string HttpMethod
- {
- get { return "GET"; }
- }
-
- public string Path
- {
- get { return "/simstatus"; }
- }
}
///
/// Handler to supply the current extended status of this sim
/// Sends the statistical data in a json serialization
///
- public class XSimStatusHandler : IStreamedRequestHandler
+ public class XSimStatusHandler : BaseStreamHandler
{
OpenSimBase m_opensim;
- string osXStatsURI = String.Empty;
-
- public string Name { get { return "XSimStatus"; } }
- public string Description { get { return "Simulator XStatus"; } }
- public XSimStatusHandler(OpenSimBase sim)
+ public XSimStatusHandler(OpenSimBase sim)
+ : base("GET", "/" + Util.SHA1Hash(sim.osSecret), "XSimStatus", "Simulator XStatus")
{
m_opensim = sim;
- osXStatsURI = Util.SHA1Hash(sim.osSecret);
}
- public byte[] Handle(string path, Stream request,
+ protected override byte[] ProcessRequest(string path, Stream request,
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{
return Util.UTF8.GetBytes(m_opensim.StatReport(httpRequest));
}
- public string ContentType
+ public override string ContentType
{
get { return "text/plain"; }
}
-
- public string HttpMethod
- {
- get { return "GET"; }
- }
-
- public string Path
- {
- // This is for the OpenSimulator instance and is the osSecret hashed
- get { return "/" + osXStatsURI; }
- }
}
///
@@ -832,42 +776,26 @@ namespace OpenSim
/// If the request contains a key, "callback" the response will be wrappend in the
/// associated value for jsonp used with ajax/javascript
///
- public class UXSimStatusHandler : IStreamedRequestHandler
+ protected class UXSimStatusHandler : BaseStreamHandler
{
OpenSimBase m_opensim;
- string osUXStatsURI = String.Empty;
-
- public string Name { get { return "UXSimStatus"; } }
- public string Description { get { return "Simulator UXStatus"; } }
public UXSimStatusHandler(OpenSimBase sim)
+ : base("GET", "/" + sim.userStatsURI, "UXSimStatus", "Simulator UXStatus")
{
- m_opensim = sim;
- osUXStatsURI = sim.userStatsURI;
-
+ m_opensim = sim;
}
- public byte[] Handle(string path, Stream request,
+ protected override byte[] ProcessRequest(string path, Stream request,
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{
return Util.UTF8.GetBytes(m_opensim.StatReport(httpRequest));
}
- public string ContentType
+ public override string ContentType
{
get { return "text/plain"; }
}
-
- public string HttpMethod
- {
- get { return "GET"; }
- }
-
- public string Path
- {
- // This is for the OpenSimulator instance and is the user provided URI
- get { return "/" + osUXStatsURI; }
- }
}
#endregion
@@ -875,7 +803,7 @@ namespace OpenSim
///
/// Performs any last-minute sanity checking and shuts down the region server
///
- public override void ShutdownSpecific()
+ protected override void ShutdownSpecific()
{
if (proxyUrl.Length > 0)
{
@@ -890,11 +818,16 @@ namespace OpenSim
try
{
SceneManager.Close();
+
+ foreach (IApplicationPlugin plugin in m_plugins)
+ plugin.Dispose();
}
catch (Exception e)
{
m_log.Error("[SHUTDOWN]: Ignoring failure during shutdown - ", e);
}
+
+ base.ShutdownSpecific();
}
///
@@ -942,7 +875,7 @@ namespace OpenSim
regInfo.EstateSettings = EstateDataService.LoadEstateSettings(regInfo.RegionID, true);
string newName;
- if (estateName != null && estateName != "")
+ if (!string.IsNullOrEmpty(estateName))
newName = estateName;
else
newName = MainConsole.Instance.CmdPrompt("New estate name", regInfo.EstateSettings.EstateName);
@@ -960,7 +893,7 @@ namespace OpenSim
// back to the default. The reloading of estate settings by scene could be eliminated if it
// knows that the passed in settings in RegionInfo are already valid. Also, it might be
// possible to eliminate some additional later saves made by callers of this method.
- regInfo.EstateSettings.Save();
+ EstateDataService.StoreEstateSettings(regInfo.EstateSettings);
return true;
}
@@ -1082,4 +1015,4 @@ namespace OpenSim
{
public IConfigSource Source;
}
-}
\ No newline at end of file
+}
--
cgit v1.1