- 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
Dr Scofield 2009-06-25 07:50:02 +00:00
parent afd5f76648
commit 8f5efc4994
2 changed files with 69 additions and 36 deletions

View File

@ -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,7 +191,10 @@ 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);
EndPoint epProxy = null;
try
{
if (EndReceive(out numBytes, result, ref epSender)) if (EndReceive(out numBytes, result, ref epSender))
{ {
// Make sure we are getting zeroes when running off the // Make sure we are getting zeroes when running off the
@ -216,7 +222,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
} }
} }
EndPoint epProxy = null;
if (proxyPortOffset != 0) if (proxyPortOffset != 0)
{ {
@ -230,6 +235,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
// Now decode the message from the proxy server // Now decode the message from the proxy server
epSender = ProxyCodec.DecodeProxyMessage(RecvBuffer, ref numBytes); epSender = ProxyCodec.DecodeProxyMessage(RecvBuffer, ref numBytes);
} }
}
catch (Exception ex)
{
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;

View File

@ -355,6 +355,23 @@
; 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]
; Controls whether the chat module is enabled. Default is true. ; Controls whether the chat module is enabled. Default is true.