From 16b43b8bffff8f11f0f633d8f503e752223a4772 Mon Sep 17 00:00:00 2001
From: Adam Frisby
Date: Thu, 14 Jun 2007 14:36:40 +0000
Subject: * Added maintenance patch (issue #139) from BigfootAg to /trunk
---
Common/OpenSim.Servers/OpenSim.Servers.csproj | 3 +
Common/OpenSim.Servers/OpenSim.Servers.dll.build | 1 +
Common/OpenSim.Servers/SocketRegistry.cs | 63 +++++++++
Common/OpenSim.Servers/UDPServerBase.cs | 8 ++
.../OpenGrid.Config.GridConfigDb4o.dll.build | 4 +-
.../OpenGrid.Framework.Manager.dll.build | 6 +-
.../OpenGridServices.AssetServer.exe.build | 10 +-
.../OpenGridServices.GridServer.exe.build | 10 +-
.../OpenGridServices.InventoryServer.csproj.user | 2 +-
.../OpenGridServices.InventoryServer.exe.build | 10 +-
.../OpenGridServices.UserServer.exe.build | 10 +-
.../OpenUser.Config.UserConfigDb4o.dll.build | 4 +-
.../ServiceManager/ServiceManager.exe.build | 4 +-
OpenSim/OpenSim.RegionServer/UDPServer.cs | 11 +-
OpenSim/OpenSim/Application.cs | 153 ++++++++++++---------
Prebuild/Prebuild.sln | 26 ++--
16 files changed, 213 insertions(+), 112 deletions(-)
create mode 100644 Common/OpenSim.Servers/SocketRegistry.cs
diff --git a/Common/OpenSim.Servers/OpenSim.Servers.csproj b/Common/OpenSim.Servers/OpenSim.Servers.csproj
index a4f56fe..7a99206 100644
--- a/Common/OpenSim.Servers/OpenSim.Servers.csproj
+++ b/Common/OpenSim.Servers/OpenSim.Servers.csproj
@@ -113,6 +113,9 @@
Code
+
+ Code
+
Code
diff --git a/Common/OpenSim.Servers/OpenSim.Servers.dll.build b/Common/OpenSim.Servers/OpenSim.Servers.dll.build
index 25bcd65..6147ea7 100644
--- a/Common/OpenSim.Servers/OpenSim.Servers.dll.build
+++ b/Common/OpenSim.Servers/OpenSim.Servers.dll.build
@@ -18,6 +18,7 @@
+
diff --git a/Common/OpenSim.Servers/SocketRegistry.cs b/Common/OpenSim.Servers/SocketRegistry.cs
new file mode 100644
index 0000000..2ebf80c
--- /dev/null
+++ b/Common/OpenSim.Servers/SocketRegistry.cs
@@ -0,0 +1,63 @@
+/*
+ * Created by SharpDevelop.
+ * User: Adam Stevenson
+ * Date: 6/13/2007
+ * Time: 12:55 AM
+ *
+ * To change this template use Tools | Options | Coding | Edit Standard Headers.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Net;
+using System.Net.Sockets;
+
+namespace OpenSim.Servers
+{
+ ///
+ ///
+ ///
+ public class SocketRegistry
+ {
+ static List _Sockets;
+
+ static SocketRegistry()
+ {
+ _Sockets = new List();
+ }
+
+ private SocketRegistry()
+ {
+
+ }
+
+ public static void Register(Socket pSocket)
+ {
+ _Sockets.Add(pSocket);
+ }
+
+ public static void Unregister(Socket pSocket)
+ {
+ _Sockets.Remove(pSocket);
+ }
+
+ public static void UnregisterAllAndClose()
+ {
+ int iSockets = _Sockets.Count;
+
+ for (int i = 0; i < iSockets; i++)
+ {
+ try
+ {
+ _Sockets[i].Close();
+ }
+ catch
+ {
+
+ }
+ }
+
+ _Sockets.Clear();
+ }
+ }
+}
diff --git a/Common/OpenSim.Servers/UDPServerBase.cs b/Common/OpenSim.Servers/UDPServerBase.cs
index b472c97..b763315 100644
--- a/Common/OpenSim.Servers/UDPServerBase.cs
+++ b/Common/OpenSim.Servers/UDPServerBase.cs
@@ -78,6 +78,13 @@ namespace OpenSim.Servers
ServerIncoming = new IPEndPoint(IPAddress.Any, listenPort);
Server = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
+
+ /// Add this new socket to the list of sockets that was opened by the application. When the application
+ /// closes, either gracefully or not, all sockets can be cleaned up. Right now I am not aware of any method
+ /// to get all of the sockets for a process within .NET, but if so, this process can be refactored, as
+ /// socket registration would not be neccessary.
+ SocketRegistry.Register(Server);
+
Server.Bind(ServerIncoming);
ipeSender = new IPEndPoint(IPAddress.Any, 0);
@@ -93,3 +100,4 @@ namespace OpenSim.Servers
}
}
+
diff --git a/OpenGridServices/OpenGrid.Config/GridConfigDb4o/OpenGrid.Config.GridConfigDb4o.dll.build b/OpenGridServices/OpenGrid.Config/GridConfigDb4o/OpenGrid.Config.GridConfigDb4o.dll.build
index 075593b..d0ba0a8 100644
--- a/OpenGridServices/OpenGrid.Config/GridConfigDb4o/OpenGrid.Config.GridConfigDb4o.dll.build
+++ b/OpenGridServices/OpenGrid.Config/GridConfigDb4o/OpenGrid.Config.GridConfigDb4o.dll.build
@@ -21,8 +21,8 @@
-
-
+
+
diff --git a/OpenGridServices/OpenGrid.Framework.Manager/OpenGrid.Framework.Manager.dll.build b/OpenGridServices/OpenGrid.Framework.Manager/OpenGrid.Framework.Manager.dll.build
index 9430ab9..7195699 100644
--- a/OpenGridServices/OpenGrid.Framework.Manager/OpenGrid.Framework.Manager.dll.build
+++ b/OpenGridServices/OpenGrid.Framework.Manager/OpenGrid.Framework.Manager.dll.build
@@ -20,10 +20,10 @@
-
-
+
+
-
+
diff --git a/OpenGridServices/OpenGridServices.AssetServer/OpenGridServices.AssetServer.exe.build b/OpenGridServices/OpenGridServices.AssetServer/OpenGridServices.AssetServer.exe.build
index 808f015..f9976e3 100644
--- a/OpenGridServices/OpenGridServices.AssetServer/OpenGridServices.AssetServer.exe.build
+++ b/OpenGridServices/OpenGridServices.AssetServer/OpenGridServices.AssetServer.exe.build
@@ -22,14 +22,14 @@
-
-
-
-
+
+
+
+
-
+
diff --git a/OpenGridServices/OpenGridServices.GridServer/OpenGridServices.GridServer.exe.build b/OpenGridServices/OpenGridServices.GridServer/OpenGridServices.GridServer.exe.build
index 60c0f85..f8951b7 100644
--- a/OpenGridServices/OpenGridServices.GridServer/OpenGridServices.GridServer.exe.build
+++ b/OpenGridServices/OpenGridServices.GridServer/OpenGridServices.GridServer.exe.build
@@ -24,14 +24,14 @@
-
-
-
-
+
+
+
+
-
+
diff --git a/OpenGridServices/OpenGridServices.InventoryServer/OpenGridServices.InventoryServer.csproj.user b/OpenGridServices/OpenGridServices.InventoryServer/OpenGridServices.InventoryServer.csproj.user
index ea58087..179959e 100644
--- a/OpenGridServices/OpenGridServices.InventoryServer/OpenGridServices.InventoryServer.csproj.user
+++ b/OpenGridServices/OpenGridServices.InventoryServer/OpenGridServices.InventoryServer.csproj.user
@@ -2,7 +2,7 @@
Debug
AnyCPU
- C:\Documents and Settings\Stefan\My Documents\source\opensim\trunk\bin\
+ E:\work\oslauth\sim\trunk\bin\
8.0.50727
ProjectFiles
0
diff --git a/OpenGridServices/OpenGridServices.InventoryServer/OpenGridServices.InventoryServer.exe.build b/OpenGridServices/OpenGridServices.InventoryServer/OpenGridServices.InventoryServer.exe.build
index 5e67af1..ff980ad 100644
--- a/OpenGridServices/OpenGridServices.InventoryServer/OpenGridServices.InventoryServer.exe.build
+++ b/OpenGridServices/OpenGridServices.InventoryServer/OpenGridServices.InventoryServer.exe.build
@@ -22,14 +22,14 @@
-
-
-
-
+
+
+
+
-
+
diff --git a/OpenGridServices/OpenGridServices.UserServer/OpenGridServices.UserServer.exe.build b/OpenGridServices/OpenGridServices.UserServer/OpenGridServices.UserServer.exe.build
index 68cbef7..894c282 100644
--- a/OpenGridServices/OpenGridServices.UserServer/OpenGridServices.UserServer.exe.build
+++ b/OpenGridServices/OpenGridServices.UserServer/OpenGridServices.UserServer.exe.build
@@ -23,14 +23,14 @@
-
-
-
-
+
+
+
+
-
+
diff --git a/OpenGridServices/OpenUser.Config/UserConfigDb4o/OpenUser.Config.UserConfigDb4o.dll.build b/OpenGridServices/OpenUser.Config/UserConfigDb4o/OpenUser.Config.UserConfigDb4o.dll.build
index bd5d49f..31801c7 100644
--- a/OpenGridServices/OpenUser.Config/UserConfigDb4o/OpenUser.Config.UserConfigDb4o.dll.build
+++ b/OpenGridServices/OpenUser.Config/UserConfigDb4o/OpenUser.Config.UserConfigDb4o.dll.build
@@ -21,8 +21,8 @@
-
-
+
+
diff --git a/OpenGridServices/ServiceManager/ServiceManager.exe.build b/OpenGridServices/ServiceManager/ServiceManager.exe.build
index e0502c6..d50b1bb 100644
--- a/OpenGridServices/ServiceManager/ServiceManager.exe.build
+++ b/OpenGridServices/ServiceManager/ServiceManager.exe.build
@@ -19,8 +19,8 @@
-
-
+
+
diff --git a/OpenSim/OpenSim.RegionServer/UDPServer.cs b/OpenSim/OpenSim.RegionServer/UDPServer.cs
index f0d3367..ae62607 100644
--- a/OpenSim/OpenSim.RegionServer/UDPServer.cs
+++ b/OpenSim/OpenSim.RegionServer/UDPServer.cs
@@ -61,7 +61,7 @@ namespace OpenSim.RegionServer
public class UDPServer : OpenSimNetworkHandler
{
protected Dictionary clientCircuits = new Dictionary();
- public Socket Server;
+ private Socket Server;
protected IPEndPoint ServerIncoming;
protected byte[] RecvBuffer = new byte[4096];
protected byte[] ZeroBuffer = new byte[8192];
@@ -201,6 +201,13 @@ namespace OpenSim.RegionServer
ServerIncoming = new IPEndPoint(IPAddress.Any, listenPort);
Server = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
+
+ /// Add this new socket to the list of sockets that was opened by the application. When the application
+ /// closes, either gracefully or not, all sockets can be cleaned up. Right now I am not aware of any method
+ /// to get all of the sockets for a process within .NET, but if so, this process can be refactored, as
+ /// socket registration would not be neccessary.
+ SocketRegistry.Register(Server);
+
Server.Bind(ServerIncoming);
m_console.Notice("UDPServer.cs:ServerListener() - UDP socket bound, getting ready to listen");
@@ -255,4 +262,4 @@ namespace OpenSim.RegionServer
return this.AuthenticateHandler(sessionID, agentID, circuitCode);
}
}
-}
\ No newline at end of file
+}
diff --git a/OpenSim/OpenSim/Application.cs b/OpenSim/OpenSim/Application.cs
index e3b23ad..15fcd93 100644
--- a/OpenSim/OpenSim/Application.cs
+++ b/OpenSim/OpenSim/Application.cs
@@ -41,84 +41,103 @@ namespace OpenSim
[STAThread]
public static void Main(string[] args)
{
- Console.WriteLine("OpenSim " + VersionInfo.Version + "\n");
- Console.WriteLine("Starting...\n");
-
- bool sandBoxMode = false;
- bool startLoginServer = false;
- string physicsEngine = "basicphysics";
- bool allowFlying = false;
- bool userAccounts = false;
- bool gridLocalAsset = false;
- bool useConfigFile = false;
- bool silent = false;
- string configFile = "simconfig.xml";
-
- for (int i = 0; i < args.Length; i++)
+ try
{
- if (args[i] == "-sandbox")
- {
- sandBoxMode = true;
- userAccounts = true;
- startLoginServer = true;
- }
- /*
- if (args[i] == "-loginserver")
- {
- startLoginServer = true;
- }*/
- if (args[i] == "-accounts")
- {
- userAccounts = true;
- }
- if (args[i] == "-realphysx")
- {
- physicsEngine = "RealPhysX";
- allowFlying = true;
- }
- if (args[i] == "-ode")
- {
- physicsEngine = "OpenDynamicsEngine";
- allowFlying = true;
- }
- if (args[i] == "-localasset")
- {
- gridLocalAsset = true;
- }
- if (args[i] == "-configfile")
- {
- useConfigFile = true;
- }
- if (args[i] == "-noverbose")
- {
- silent = true;
- }
- if (args[i] == "-config")
+ Console.WriteLine("OpenSim " + VersionInfo.Version + "\n");
+ Console.WriteLine("Starting...\n");
+
+ bool sandBoxMode = false;
+ bool startLoginServer = false;
+ string physicsEngine = "basicphysics";
+ bool allowFlying = false;
+ bool userAccounts = false;
+ bool gridLocalAsset = false;
+ bool useConfigFile = false;
+ bool silent = false;
+ string configFile = "simconfig.xml";
+
+ for (int i = 0; i < args.Length; i++)
{
- try
+ if (args[i] == "-sandbox")
{
- i++;
- configFile = args[i];
+ sandBoxMode = true;
+ userAccounts = true;
+ startLoginServer = true;
}
- catch (Exception e)
+ /*
+ if (args[i] == "-loginserver")
{
- Console.WriteLine("-config: Please specify a config file. (" + e.ToString() + ")");
+ startLoginServer = true;
+ }*/
+ if (args[i] == "-accounts")
+ {
+ userAccounts = true;
+ }
+ if (args[i] == "-realphysx")
+ {
+ physicsEngine = "RealPhysX";
+ allowFlying = true;
+ }
+ if (args[i] == "-ode")
+ {
+ physicsEngine = "OpenDynamicsEngine";
+ allowFlying = true;
+ }
+ if (args[i] == "-localasset")
+ {
+ gridLocalAsset = true;
+ }
+ if (args[i] == "-configfile")
+ {
+ useConfigFile = true;
+ }
+ if (args[i] == "-noverbose")
+ {
+ silent = true;
+ }
+ if (args[i] == "-config")
+ {
+ try
+ {
+ i++;
+ configFile = args[i];
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("-config: Please specify a config file. (" + e.ToString() + ")");
+ }
}
}
- }
- OpenSimMain sim = new OpenSimMain(sandBoxMode, startLoginServer, physicsEngine, useConfigFile, silent, configFile);
- // OpenSimRoot.Instance.Application = sim;
- sim.m_sandbox = sandBoxMode;
- sim.user_accounts = userAccounts;
- sim.gridLocalAsset = gridLocalAsset;
- OpenSim.RegionServer.Simulator.Avatar.PhysicsEngineFlying = allowFlying;
+ OpenSimMain sim = new OpenSimMain(sandBoxMode, startLoginServer, physicsEngine, useConfigFile, silent, configFile);
+ // OpenSimRoot.Instance.Application = sim;
+ sim.m_sandbox = sandBoxMode;
+ sim.user_accounts = userAccounts;
+ sim.gridLocalAsset = gridLocalAsset;
+ OpenSim.RegionServer.Simulator.Avatar.PhysicsEngineFlying = allowFlying;
- sim.StartUp();
+ sim.StartUp();
- while (true)
+ while (true)
+ {
+ OpenSim.Framework.Console.MainConsole.Instance.MainConsolePrompt();
+ }
+ }
+ catch (Exception oException)
+ {
+ Console.WriteLine(oException.Message);
+ Console.WriteLine("Fatal error. Server is shutdown. Press 'Enter' to close.");
+ Console.ReadLine();
+
+ }
+ finally
{
- OpenSim.Framework.Console.MainConsole.Instance.MainConsolePrompt();
+ /// Ensure that all sockets have been closed before the process closes. This helps ensure that no
+ /// open ports are left open on process that ''. This is in the finally block, as it
+ /// should be done regardless of whether a exception closes the application, or if the application
+ /// is closed normally.
+
+ OpenSim.Servers.SocketRegistry.UnregisterAllAndClose();
}
}
}
diff --git a/Prebuild/Prebuild.sln b/Prebuild/Prebuild.sln
index 227677f..449896b 100644
--- a/Prebuild/Prebuild.sln
+++ b/Prebuild/Prebuild.sln
@@ -3,17 +3,17 @@ Microsoft Visual Studio Solution File, Format Version 9.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Prebuild", "src\Prebuild.csproj", "{92E80C1C-0000-0000-0000-000000000000}"
EndProject
Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Any CPU = Debug|Any CPU
- Release|Any CPU = Release|Any CPU
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {92E80C1C-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {92E80C1C-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {92E80C1C-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {92E80C1C-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {92E80C1C-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {92E80C1C-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {92E80C1C-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {92E80C1C-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
EndGlobal
--
cgit v1.1