Merge branch 'master' into careminster
commit
c4fcfec24e
|
@ -37,6 +37,7 @@ using log4net;
|
||||||
using Nini.Config;
|
using Nini.Config;
|
||||||
using OpenMetaverse.Packets;
|
using OpenMetaverse.Packets;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
|
using OpenSim.Framework.Console;
|
||||||
using OpenSim.Framework.Monitoring;
|
using OpenSim.Framework.Monitoring;
|
||||||
using OpenSim.Region.Framework.Scenes;
|
using OpenSim.Region.Framework.Scenes;
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
|
@ -278,16 +279,21 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
|
|
||||||
public void Start()
|
public void Start()
|
||||||
{
|
{
|
||||||
if (m_scene == null)
|
StartInbound();
|
||||||
throw new InvalidOperationException("[LLUDPSERVER]: Cannot LLUDPServer.Start() without an IScene reference");
|
StartOutbound();
|
||||||
|
|
||||||
|
m_elapsedMSSinceLastStatReport = Environment.TickCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void StartInbound()
|
||||||
|
{
|
||||||
m_log.InfoFormat(
|
m_log.InfoFormat(
|
||||||
"[LLUDPSERVER]: Starting the LLUDP server in {0} mode",
|
"[LLUDPSERVER]: Starting inbound packet processing for the LLUDP server in {0} mode",
|
||||||
m_asyncPacketHandling ? "asynchronous" : "synchronous");
|
m_asyncPacketHandling ? "asynchronous" : "synchronous");
|
||||||
|
|
||||||
base.Start(m_recvBufferSize, m_asyncPacketHandling);
|
base.StartInbound(m_recvBufferSize, m_asyncPacketHandling);
|
||||||
|
|
||||||
// Start the packet processing threads
|
// This thread will process the packets received that are placed on the packetInbox
|
||||||
Watchdog.StartThread(
|
Watchdog.StartThread(
|
||||||
IncomingPacketHandler,
|
IncomingPacketHandler,
|
||||||
string.Format("Incoming Packets ({0})", m_scene.RegionInfo.RegionName),
|
string.Format("Incoming Packets ({0})", m_scene.RegionInfo.RegionName),
|
||||||
|
@ -296,7 +302,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
true,
|
true,
|
||||||
GetWatchdogIncomingAlarmData,
|
GetWatchdogIncomingAlarmData,
|
||||||
Watchdog.DEFAULT_WATCHDOG_TIMEOUT_MS);
|
Watchdog.DEFAULT_WATCHDOG_TIMEOUT_MS);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void StartOutbound()
|
||||||
|
{
|
||||||
|
m_log.Info("[LLUDPSERVER]: Starting outbound packet processing for the LLUDP server");
|
||||||
|
|
||||||
|
base.StartOutbound();
|
||||||
|
|
||||||
|
// This thread will process the packets received that are placed on the packetInbox
|
||||||
Watchdog.StartThread(
|
Watchdog.StartThread(
|
||||||
OutgoingPacketHandler,
|
OutgoingPacketHandler,
|
||||||
string.Format("Outgoing Packets ({0})", m_scene.RegionInfo.RegionName),
|
string.Format("Outgoing Packets ({0})", m_scene.RegionInfo.RegionName),
|
||||||
|
@ -305,8 +319,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
true,
|
true,
|
||||||
GetWatchdogOutgoingAlarmData,
|
GetWatchdogOutgoingAlarmData,
|
||||||
Watchdog.DEFAULT_WATCHDOG_TIMEOUT_MS);
|
Watchdog.DEFAULT_WATCHDOG_TIMEOUT_MS);
|
||||||
|
}
|
||||||
|
|
||||||
m_elapsedMSSinceLastStatReport = Environment.TickCount;
|
public new void Stop()
|
||||||
|
{
|
||||||
|
m_log.Info("[LLUDPSERVER]: Shutting down the LLUDP server for " + m_scene.RegionInfo.RegionName);
|
||||||
|
base.StopOutbound();
|
||||||
|
base.StopInbound();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -331,12 +350,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
m_currentOutgoingClient != null ? m_currentOutgoingClient.Name : "none");
|
m_currentOutgoingClient != null ? m_currentOutgoingClient.Name : "none");
|
||||||
}
|
}
|
||||||
|
|
||||||
public new void Stop()
|
|
||||||
{
|
|
||||||
m_log.Info("[LLUDPSERVER]: Shutting down the LLUDP server for " + m_scene.RegionInfo.RegionName);
|
|
||||||
base.Stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void AddScene(IScene scene)
|
public void AddScene(IScene scene)
|
||||||
{
|
{
|
||||||
if (m_scene != null)
|
if (m_scene != null)
|
||||||
|
@ -353,6 +366,81 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
|
|
||||||
m_scene = (Scene)scene;
|
m_scene = (Scene)scene;
|
||||||
m_location = new Location(m_scene.RegionInfo.RegionHandle);
|
m_location = new Location(m_scene.RegionInfo.RegionHandle);
|
||||||
|
|
||||||
|
MainConsole.Instance.Commands.AddCommand(
|
||||||
|
"Debug",
|
||||||
|
false,
|
||||||
|
"debug lludp start",
|
||||||
|
"debug lludp start <in|out|all>",
|
||||||
|
"Control LLUDP packet processing.",
|
||||||
|
"No effect if packet processing has already started.\n"
|
||||||
|
+ "in - start inbound processing.\n"
|
||||||
|
+ "out - start outbound processing.\n"
|
||||||
|
+ "all - start in and outbound processing.\n",
|
||||||
|
HandleStartCommand);
|
||||||
|
|
||||||
|
MainConsole.Instance.Commands.AddCommand(
|
||||||
|
"Debug",
|
||||||
|
false,
|
||||||
|
"debug lludp stop",
|
||||||
|
"debug lludp stop <in|out|all>",
|
||||||
|
"Stop LLUDP packet processing.",
|
||||||
|
"No effect if packet processing has already stopped.\n"
|
||||||
|
+ "in - stop inbound processing.\n"
|
||||||
|
+ "out - stop outbound processing.\n"
|
||||||
|
+ "all - stop in and outbound processing.\n",
|
||||||
|
HandleStopCommand);
|
||||||
|
|
||||||
|
MainConsole.Instance.Commands.AddCommand(
|
||||||
|
"Debug",
|
||||||
|
false,
|
||||||
|
"debug lludp status",
|
||||||
|
"debug lludp status",
|
||||||
|
"Return status of LLUDP packet processing.",
|
||||||
|
HandleStatusCommand);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HandleStartCommand(string module, string[] args)
|
||||||
|
{
|
||||||
|
if (args.Length != 4)
|
||||||
|
{
|
||||||
|
MainConsole.Instance.Output("Usage: debug lludp start <in|out|all>");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
string subCommand = args[3];
|
||||||
|
|
||||||
|
if (subCommand == "in" || subCommand == "all")
|
||||||
|
StartInbound();
|
||||||
|
|
||||||
|
if (subCommand == "out" || subCommand == "all")
|
||||||
|
StartOutbound();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HandleStopCommand(string module, string[] args)
|
||||||
|
{
|
||||||
|
if (args.Length != 4)
|
||||||
|
{
|
||||||
|
MainConsole.Instance.Output("Usage: debug lludp stop <in|out|all>");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
string subCommand = args[3];
|
||||||
|
|
||||||
|
if (subCommand == "in" || subCommand == "all")
|
||||||
|
StopInbound();
|
||||||
|
|
||||||
|
if (subCommand == "out" || subCommand == "all")
|
||||||
|
StopOutbound();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HandleStatusCommand(string module, string[] args)
|
||||||
|
{
|
||||||
|
MainConsole.Instance.OutputFormat(
|
||||||
|
"IN LLUDP packet processing for {0} is {1}", m_scene.Name, IsRunningInbound ? "enabled" : "disabled");
|
||||||
|
|
||||||
|
MainConsole.Instance.OutputFormat(
|
||||||
|
"OUT LLUDP packet processing for {0} is {1}", m_scene.Name, IsRunningOutbound ? "enabled" : "disabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool HandlesRegion(Location x)
|
public bool HandlesRegion(Location x)
|
||||||
|
@ -1239,7 +1327,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
// on to en-US to avoid number parsing issues
|
// on to en-US to avoid number parsing issues
|
||||||
Culture.SetCurrentCulture();
|
Culture.SetCurrentCulture();
|
||||||
|
|
||||||
while (base.IsRunning)
|
while (base.IsRunningInbound)
|
||||||
{
|
{
|
||||||
m_scene.ThreadAlive(1);
|
m_scene.ThreadAlive(1);
|
||||||
try
|
try
|
||||||
|
@ -1282,7 +1370,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
// Action generic every round
|
// Action generic every round
|
||||||
Action<IClientAPI> clientPacketHandler = ClientOutgoingPacketHandler;
|
Action<IClientAPI> clientPacketHandler = ClientOutgoingPacketHandler;
|
||||||
|
|
||||||
while (base.IsRunning)
|
while (base.IsRunningOutbound)
|
||||||
{
|
{
|
||||||
m_scene.ThreadAlive(2);
|
m_scene.ThreadAlive(2);
|
||||||
try
|
try
|
||||||
|
|
|
@ -58,11 +58,12 @@ namespace OpenMetaverse
|
||||||
/// <summary>Flag to process packets asynchronously or synchronously</summary>
|
/// <summary>Flag to process packets asynchronously or synchronously</summary>
|
||||||
private bool m_asyncPacketHandling;
|
private bool m_asyncPacketHandling;
|
||||||
|
|
||||||
/// <summary>The all important shutdown flag</summary>
|
/// <summary>Returns true if the server is currently listening for inbound packets, otherwise false</summary>
|
||||||
private volatile bool m_shutdownFlag = true;
|
public bool IsRunningInbound { get; private set; }
|
||||||
|
|
||||||
/// <summary>Returns true if the server is currently listening, otherwise false</summary>
|
/// <summary>Returns true if the server is currently sending outbound packets, otherwise false</summary>
|
||||||
public bool IsRunning { get { return !m_shutdownFlag; } }
|
/// <remarks>If IsRunningOut = false, then any request to send a packet is simply dropped.</remarks>
|
||||||
|
public bool IsRunningOutbound { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Default constructor
|
/// Default constructor
|
||||||
|
@ -76,7 +77,7 @@ namespace OpenMetaverse
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Start the UDP server
|
/// Start inbound UDP packet handling.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="recvBufferSize">The size of the receive buffer for
|
/// <param name="recvBufferSize">The size of the receive buffer for
|
||||||
/// the UDP socket. This value is passed up to the operating system
|
/// the UDP socket. This value is passed up to the operating system
|
||||||
|
@ -91,11 +92,11 @@ namespace OpenMetaverse
|
||||||
/// manner (not throwing an exception when the remote side resets the
|
/// manner (not throwing an exception when the remote side resets the
|
||||||
/// connection). This call is ignored on Mono where the flag is not
|
/// connection). This call is ignored on Mono where the flag is not
|
||||||
/// necessary</remarks>
|
/// necessary</remarks>
|
||||||
public void Start(int recvBufferSize, bool asyncPacketHandling)
|
public void StartInbound(int recvBufferSize, bool asyncPacketHandling)
|
||||||
{
|
{
|
||||||
m_asyncPacketHandling = asyncPacketHandling;
|
m_asyncPacketHandling = asyncPacketHandling;
|
||||||
|
|
||||||
if (m_shutdownFlag)
|
if (!IsRunningInbound)
|
||||||
{
|
{
|
||||||
const int SIO_UDP_CONNRESET = -1744830452;
|
const int SIO_UDP_CONNRESET = -1744830452;
|
||||||
|
|
||||||
|
@ -123,8 +124,7 @@ namespace OpenMetaverse
|
||||||
|
|
||||||
m_udpSocket.Bind(ipep);
|
m_udpSocket.Bind(ipep);
|
||||||
|
|
||||||
// we're not shutting down, we're starting up
|
IsRunningInbound = true;
|
||||||
m_shutdownFlag = false;
|
|
||||||
|
|
||||||
// kick off an async receive. The Start() method will return, the
|
// kick off an async receive. The Start() method will return, the
|
||||||
// actual receives will occur asynchronously and will be caught in
|
// actual receives will occur asynchronously and will be caught in
|
||||||
|
@ -134,28 +134,38 @@ namespace OpenMetaverse
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Stops the UDP server
|
/// Start outbound UDP packet handling.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Stop()
|
public void StartOutbound()
|
||||||
{
|
{
|
||||||
if (!m_shutdownFlag)
|
IsRunningOutbound = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void StopInbound()
|
||||||
|
{
|
||||||
|
if (IsRunningInbound)
|
||||||
{
|
{
|
||||||
// wait indefinitely for a writer lock. Once this is called, the .NET runtime
|
// wait indefinitely for a writer lock. Once this is called, the .NET runtime
|
||||||
// will deny any more reader locks, in effect blocking all other send/receive
|
// will deny any more reader locks, in effect blocking all other send/receive
|
||||||
// threads. Once we have the lock, we set shutdownFlag to inform the other
|
// threads. Once we have the lock, we set IsRunningInbound = false to inform the other
|
||||||
// threads that the socket is closed.
|
// threads that the socket is closed.
|
||||||
m_shutdownFlag = true;
|
IsRunningInbound = false;
|
||||||
m_udpSocket.Close();
|
m_udpSocket.Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void StopOutbound()
|
||||||
|
{
|
||||||
|
IsRunningOutbound = false;
|
||||||
|
}
|
||||||
|
|
||||||
private void AsyncBeginReceive()
|
private void AsyncBeginReceive()
|
||||||
{
|
{
|
||||||
// allocate a packet buffer
|
// allocate a packet buffer
|
||||||
//WrappedObject<UDPPacketBuffer> wrappedBuffer = Pool.CheckOut();
|
//WrappedObject<UDPPacketBuffer> wrappedBuffer = Pool.CheckOut();
|
||||||
UDPPacketBuffer buf = new UDPPacketBuffer();
|
UDPPacketBuffer buf = new UDPPacketBuffer();
|
||||||
|
|
||||||
if (!m_shutdownFlag)
|
if (IsRunningInbound)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -208,7 +218,7 @@ namespace OpenMetaverse
|
||||||
{
|
{
|
||||||
// Asynchronous receive operations will complete here through the call
|
// Asynchronous receive operations will complete here through the call
|
||||||
// to AsyncBeginReceive
|
// to AsyncBeginReceive
|
||||||
if (!m_shutdownFlag)
|
if (IsRunningInbound)
|
||||||
{
|
{
|
||||||
// Asynchronous mode will start another receive before the
|
// Asynchronous mode will start another receive before the
|
||||||
// callback for this packet is even fired. Very parallel :-)
|
// callback for this packet is even fired. Very parallel :-)
|
||||||
|
@ -248,7 +258,7 @@ namespace OpenMetaverse
|
||||||
|
|
||||||
public void AsyncBeginSend(UDPPacketBuffer buf)
|
public void AsyncBeginSend(UDPPacketBuffer buf)
|
||||||
{
|
{
|
||||||
if (!m_shutdownFlag)
|
if (IsRunningOutbound)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue