- adds the possibility of setting the socket receive buffer size
option for LLUDPServer. On windows .NET the default socket receive buffer size is 8192 bytes, on recent linux systems it's about 111K. both value can be a bit small for an OpenSim instance serving many clients. The socket receive buffer size can be configured via an OpenSim.ini config option - adds a general catch clause to LLUDPServer.OnReceivedData() to prevent it submerging when an unexpected Exception occurs.0.6.6-post-fixes
parent
afd5f76648
commit
8f5efc4994
|
@ -76,6 +76,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
protected IPAddress listenIP = IPAddress.Parse("0.0.0.0");
|
protected IPAddress listenIP = IPAddress.Parse("0.0.0.0");
|
||||||
protected IScene m_localScene;
|
protected IScene m_localScene;
|
||||||
protected IAssetCache m_assetCache;
|
protected IAssetCache m_assetCache;
|
||||||
|
protected int m_clientSocketReceiveBuffer = 0;
|
||||||
|
|
||||||
/// <value>
|
/// <value>
|
||||||
/// Manages authentication for agent circuits
|
/// Manages authentication for agent circuits
|
||||||
|
@ -157,6 +158,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
{
|
{
|
||||||
if (config.Contains("client_throttle_multiplier"))
|
if (config.Contains("client_throttle_multiplier"))
|
||||||
userSettings.ClientThrottleMultipler = config.GetFloat("client_throttle_multiplier");
|
userSettings.ClientThrottleMultipler = config.GetFloat("client_throttle_multiplier");
|
||||||
|
if (config.Contains("client_socket_rcvbuf_size"))
|
||||||
|
m_clientSocketReceiveBuffer = config.GetInt("client_socket_rcvbuf_size");
|
||||||
}
|
}
|
||||||
|
|
||||||
m_log.DebugFormat("[CLIENT]: client_throttle_multiplier = {0}", userSettings.ClientThrottleMultipler);
|
m_log.DebugFormat("[CLIENT]: client_throttle_multiplier = {0}", userSettings.ClientThrottleMultipler);
|
||||||
|
@ -188,47 +191,54 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
Packet packet = null;
|
Packet packet = null;
|
||||||
int numBytes = 1;
|
int numBytes = 1;
|
||||||
EndPoint epSender = new IPEndPoint(IPAddress.Any, 0);
|
EndPoint epSender = new IPEndPoint(IPAddress.Any, 0);
|
||||||
|
|
||||||
if (EndReceive(out numBytes, result, ref epSender))
|
|
||||||
{
|
|
||||||
// Make sure we are getting zeroes when running off the
|
|
||||||
// end of grab / degrab packets from old clients
|
|
||||||
Array.Clear(RecvBuffer, numBytes, RecvBuffer.Length - numBytes);
|
|
||||||
|
|
||||||
int packetEnd = numBytes - 1;
|
|
||||||
if (proxyPortOffset != 0) packetEnd -= 6;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
packet = PacketPool.Instance.GetPacket(RecvBuffer, ref packetEnd, ZeroBuffer);
|
|
||||||
}
|
|
||||||
catch (MalformedDataException e)
|
|
||||||
{
|
|
||||||
m_log.DebugFormat("[CLIENT]: Dropped Malformed Packet due to MalformedDataException: {0}", e.StackTrace);
|
|
||||||
}
|
|
||||||
catch (IndexOutOfRangeException e)
|
|
||||||
{
|
|
||||||
m_log.DebugFormat("[CLIENT]: Dropped Malformed Packet due to IndexOutOfRangeException: {0}", e.StackTrace);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
m_log.Debug("[CLIENT]: " + e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
EndPoint epProxy = null;
|
EndPoint epProxy = null;
|
||||||
|
|
||||||
if (proxyPortOffset != 0)
|
try
|
||||||
{
|
{
|
||||||
// If we've received a use circuit packet, then we need to decode an endpoint proxy, if one exists,
|
if (EndReceive(out numBytes, result, ref epSender))
|
||||||
// before allowing the RecvBuffer to be overwritten by the next packet.
|
|
||||||
if (packet != null && packet.Type == PacketType.UseCircuitCode)
|
|
||||||
{
|
{
|
||||||
epProxy = epSender;
|
// Make sure we are getting zeroes when running off the
|
||||||
|
// end of grab / degrab packets from old clients
|
||||||
|
Array.Clear(RecvBuffer, numBytes, RecvBuffer.Length - numBytes);
|
||||||
|
|
||||||
|
int packetEnd = numBytes - 1;
|
||||||
|
if (proxyPortOffset != 0) packetEnd -= 6;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
packet = PacketPool.Instance.GetPacket(RecvBuffer, ref packetEnd, ZeroBuffer);
|
||||||
|
}
|
||||||
|
catch (MalformedDataException e)
|
||||||
|
{
|
||||||
|
m_log.DebugFormat("[CLIENT]: Dropped Malformed Packet due to MalformedDataException: {0}", e.StackTrace);
|
||||||
|
}
|
||||||
|
catch (IndexOutOfRangeException e)
|
||||||
|
{
|
||||||
|
m_log.DebugFormat("[CLIENT]: Dropped Malformed Packet due to IndexOutOfRangeException: {0}", e.StackTrace);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
m_log.Debug("[CLIENT]: " + e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (proxyPortOffset != 0)
|
||||||
|
{
|
||||||
|
// If we've received a use circuit packet, then we need to decode an endpoint proxy, if one exists,
|
||||||
|
// before allowing the RecvBuffer to be overwritten by the next packet.
|
||||||
|
if (packet != null && packet.Type == PacketType.UseCircuitCode)
|
||||||
|
{
|
||||||
|
epProxy = epSender;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now decode the message from the proxy server
|
||||||
|
epSender = ProxyCodec.DecodeProxyMessage(RecvBuffer, ref numBytes);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Now decode the message from the proxy server
|
catch (Exception ex)
|
||||||
epSender = ProxyCodec.DecodeProxyMessage(RecvBuffer, ref numBytes);
|
{
|
||||||
|
m_log.ErrorFormat("[CLIENT]: Exception thrown during EndReceive(): {0}", ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
BeginRobustReceive();
|
BeginRobustReceive();
|
||||||
|
@ -324,6 +334,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
|
|
||||||
done = true;
|
done = true;
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
m_log.ErrorFormat("[CLIENT]: Exception thrown during BeginReceive(): {0}", ex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -472,6 +486,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
|
|
||||||
ServerIncoming = new IPEndPoint(listenIP, (int)newPort);
|
ServerIncoming = new IPEndPoint(listenIP, (int)newPort);
|
||||||
m_socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
|
m_socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
|
||||||
|
if (0 != m_clientSocketReceiveBuffer)
|
||||||
|
m_socket.ReceiveBufferSize = m_clientSocketReceiveBuffer;
|
||||||
m_socket.Bind(ServerIncoming);
|
m_socket.Bind(ServerIncoming);
|
||||||
// Add flags to the UDP socket to prevent "Socket forcibly closed by host"
|
// Add flags to the UDP socket to prevent "Socket forcibly closed by host"
|
||||||
// uint IOC_IN = 0x80000000;
|
// uint IOC_IN = 0x80000000;
|
||||||
|
|
|
@ -354,6 +354,23 @@
|
||||||
; Pre r7113, this setting was not exposed but was effectively 8. You may want to try this if you encounter
|
; Pre r7113, this setting was not exposed but was effectively 8. You may want to try this if you encounter
|
||||||
; unexpected difficulties
|
; unexpected difficulties
|
||||||
client_throttle_multiplier = 2;
|
client_throttle_multiplier = 2;
|
||||||
|
|
||||||
|
; the client socket receive buffer size determines how many
|
||||||
|
; incoming requests we can process; the default on .NET is 8192
|
||||||
|
; which is about 2 4k-sized UDP datagrams. On mono this is
|
||||||
|
; whatever the underlying operating system has as default; for
|
||||||
|
; example, ubuntu 8.04 or SLES11 have about 111k, which is about
|
||||||
|
; 27 4k-sized UDP datagrams (on linux platforms you can [as root]
|
||||||
|
; do "sysctl net.core.rmem_default" to find out what your system
|
||||||
|
; uses a default socket receive buffer size.
|
||||||
|
;
|
||||||
|
; client_socket_rcvbuf_size allows you to specify the receive
|
||||||
|
; buffer size LLUDPServer should use. NOTE: this will be limited
|
||||||
|
; by the system's settings for the maximum client receive buffer
|
||||||
|
; size (on linux systems you can set that with "sysctl -w
|
||||||
|
; net.core.rmem_max=X")
|
||||||
|
;
|
||||||
|
; client_socket_rcvbuf_size = 8388608
|
||||||
|
|
||||||
|
|
||||||
[Chat]
|
[Chat]
|
||||||
|
|
Loading…
Reference in New Issue