* Added maintenance patch (issue #139) from BigfootAg to /trunk

afrisby
Adam Frisby 2007-06-14 14:36:40 +00:00
parent c8db62e0e4
commit 16b43b8bff
16 changed files with 215 additions and 114 deletions

View File

@ -113,6 +113,9 @@
<Compile Include="LoginServer.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="SocketRegistry.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="UDPServerBase.cs">
<SubType>Code</SubType>
</Compile>

View File

@ -18,6 +18,7 @@
<include name="LocalUserProfileManager.cs" />
<include name="LoginResponse.cs" />
<include name="LoginServer.cs" />
<include name="SocketRegistry.cs" />
<include name="UDPServerBase.cs" />
<include name="XmlRpcMethod.cs" />
</sources>

View File

@ -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
{
/// <summary>
///
/// </summary>
public class SocketRegistry
{
static List<Socket> _Sockets;
static SocketRegistry()
{
_Sockets = new List<Socket>();
}
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();
}
}
}

View File

@ -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
}
}

View File

@ -21,8 +21,8 @@
</lib>
<include name="../../../bin/Db4objects.Db4o.dll" />
<include name="../../../bin/libsecondlife.dll" />
<include name="../../../bin/OpenSim.Framework.dll" />
<include name="../../../bin/OpenSim.Framework.Console.dll" />
<include name="OpenSim.Framework.dll" />
<include name="OpenSim.Framework.Console.dll" />
<include name="System.dll" />
<include name="System.Data.dll.dll" />
<include name="System.Xml.dll" />

View File

@ -20,10 +20,10 @@
<include name="${project::get-base-directory()}/${build.dir}" />
</lib>
<include name="../../bin/libsecondlife.dll" />
<include name="../../bin/OpenSim.Framework.dll" />
<include name="../../bin/OpenSim.Servers.dll" />
<include name="OpenSim.Framework.dll.dll" />
<include name="OpenSim.Servers.dll.dll" />
<include name="System.dll" />
<include name="../../bin/XMLRPC.dll" />
<include name="XMLRPC.dll" />
</references>
</csc>
<echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../bin/" />

View File

@ -22,14 +22,14 @@
</lib>
<include name="../../bin/Db4objects.Db4o.dll" />
<include name="../../bin/libsecondlife.dll" />
<include name="../../bin/OpenSim.Framework.dll" />
<include name="../../bin/OpenSim.Framework.Console.dll" />
<include name="../../bin/OpenSim.GridInterfaces.Local.dll" />
<include name="../../bin/OpenSim.Servers.dll" />
<include name="OpenSim.Framework.dll" />
<include name="OpenSim.Framework.Console.dll" />
<include name="OpenSim.GridInterfaces.Local.dll" />
<include name="OpenSim.Servers.dll" />
<include name="System.dll" />
<include name="System.Data.dll" />
<include name="System.Xml.dll" />
<include name="../../bin/XMLRPC.dll" />
<include name="XMLRPC.dll" />
</references>
</csc>
<echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../bin/" />

View File

@ -24,14 +24,14 @@
<include name="../../bin/libsecondlife.dll" />
<include name="../../bin/OpenGrid.Framework.Data.dll" />
<include name="../../bin/OpenGrid.Framework.Manager.dll" />
<include name="../../bin/OpenSim.Framework.dll" />
<include name="../../bin/OpenSim.Framework.Console.dll" />
<include name="../../bin/OpenSim.GenericConfig.Xml.dll" />
<include name="../../bin/OpenSim.Servers.dll" />
<include name="OpenSim.Framework.dll" />
<include name="OpenSim.Framework.Console.dll" />
<include name="OpenSim.GenericConfig.Xml.dll" />
<include name="OpenSim.Servers.dll" />
<include name="System.dll" />
<include name="System.Data.dll" />
<include name="System.Xml.dll" />
<include name="../../bin/XMLRPC.dll" />
<include name="XMLRPC.dll" />
</references>
</csc>
<echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../bin/" />

View File

@ -2,7 +2,7 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ReferencePath>C:\Documents and Settings\Stefan\My Documents\source\opensim\trunk\bin\</ReferencePath>
<ReferencePath>E:\work\oslauth\sim\trunk\bin\</ReferencePath>
<LastOpenVersion>8.0.50727</LastOpenVersion>
<ProjectView>ProjectFiles</ProjectView>
<ProjectTrust>0</ProjectTrust>

View File

@ -22,14 +22,14 @@
<include name="../../bin/Db4objects.Db4o.dll" />
<include name="../../bin/libsecondlife.dll" />
<include name="../../bin/OpenGrid.Framework.Data.dll" />
<include name="../../bin/OpenSim.Framework.dll" />
<include name="../../bin/OpenSim.Framework.Console.dll" />
<include name="../../bin/OpenSim.GridInterfaces.Local.dll" />
<include name="../../bin/OpenSim.Servers.dll" />
<include name="OpenSim.Framework.dll" />
<include name="OpenSim.Framework.Console.dll" />
<include name="OpenSim.GridInterfaces.Local.dll" />
<include name="OpenSim.Servers.dll" />
<include name="System.dll" />
<include name="System.Data.dll" />
<include name="System.Xml.dll" />
<include name="../../bin/XMLRPC.dll" />
<include name="XMLRPC.dll" />
</references>
</csc>
<echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../bin/" />

View File

@ -23,14 +23,14 @@
<include name="../../bin/Db4objects.Db4o.dll" />
<include name="../../bin/libsecondlife.dll" />
<include name="../../bin/OpenGrid.Framework.Data.dll" />
<include name="../../bin/OpenSim.Framework.dll" />
<include name="../../bin/OpenSim.Framework.Console.dll" />
<include name="../../bin/OpenSim.GenericConfig.Xml.dll" />
<include name="../../bin/OpenSim.Servers.dll" />
<include name="OpenSim.Framework.dll" />
<include name="OpenSim.Framework.Console.dll" />
<include name="OpenSim.GenericConfig.Xml.dll" />
<include name="OpenSim.Servers.dll" />
<include name="System.dll" />
<include name="System.Data.dll" />
<include name="System.Xml.dll" />
<include name="../../bin/XMLRPC.dll" />
<include name="XMLRPC.dll" />
</references>
</csc>
<echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../bin/" />

View File

@ -21,8 +21,8 @@
</lib>
<include name="../../../bin/Db4objects.Db4o.dll" />
<include name="../../../bin/libsecondlife.dll" />
<include name="../../../bin/OpenSim.Framework.dll" />
<include name="../../../bin/OpenSim.Framework.Console.dll" />
<include name="OpenSim.Framework.dll" />
<include name="OpenSim.Framework.Console.dll" />
<include name="System.dll" />
<include name="System.Data.dll.dll" />
<include name="System.Xml.dll" />

View File

@ -19,8 +19,8 @@
<include name="${project::get-base-directory()}/${build.dir}" />
</lib>
<include name="../../bin/libsecondlife.dll" />
<include name="../../bin/OpenSim.Framework.dll" />
<include name="../../bin/OpenSim.GenericConfig.Xml.dll" />
<include name="OpenSim.Framework.dll.dll" />
<include name="OpenSim.GenericConfig.Xml.dll" />
<include name="System.dll" />
<include name="System.ServiceProcess.dll" />
<include name="System.Xml.dll" />

View File

@ -61,7 +61,7 @@ namespace OpenSim.RegionServer
public class UDPServer : OpenSimNetworkHandler
{
protected Dictionary<EndPoint, uint> clientCircuits = new Dictionary<EndPoint, uint>();
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");

View File

@ -40,6 +40,8 @@ namespace OpenSim
//could move our main function into OpenSimMain and kill this class
[STAThread]
public static void Main(string[] args)
{
try
{
Console.WriteLine("OpenSim " + VersionInfo.Version + "\n");
Console.WriteLine("Starting...\n");
@ -121,5 +123,22 @@ namespace OpenSim
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
{
/// Ensure that all sockets have been closed before the process closes. This helps ensure that no
/// open ports are left open on process that '<do not exist>'. 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();
}
}
}
}