aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDr Scofield2009-06-25 07:50:02 +0000
committerDr Scofield2009-06-25 07:50:02 +0000
commit8f5efc499456edd03d3d22e64a0151386cbf47b1 (patch)
tree1131fa8879f670ded2a26794c448afff8d89a985
parentFrom: Alan Webb <alan_webb@us.ibm.com> (diff)
downloadopensim-SC-8f5efc499456edd03d3d22e64a0151386cbf47b1.zip
opensim-SC-8f5efc499456edd03d3d22e64a0151386cbf47b1.tar.gz
opensim-SC-8f5efc499456edd03d3d22e64a0151386cbf47b1.tar.bz2
opensim-SC-8f5efc499456edd03d3d22e64a0151386cbf47b1.tar.xz
- 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.
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs86
-rw-r--r--bin/OpenSim.ini.example17
2 files changed, 68 insertions, 35 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
index 0b17d1b..24bb502 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
@@ -76,6 +76,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
76 protected IPAddress listenIP = IPAddress.Parse("0.0.0.0"); 76 protected IPAddress listenIP = IPAddress.Parse("0.0.0.0");
77 protected IScene m_localScene; 77 protected IScene m_localScene;
78 protected IAssetCache m_assetCache; 78 protected IAssetCache m_assetCache;
79 protected int m_clientSocketReceiveBuffer = 0;
79 80
80 /// <value> 81 /// <value>
81 /// Manages authentication for agent circuits 82 /// Manages authentication for agent circuits
@@ -157,6 +158,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
157 { 158 {
158 if (config.Contains("client_throttle_multiplier")) 159 if (config.Contains("client_throttle_multiplier"))
159 userSettings.ClientThrottleMultipler = config.GetFloat("client_throttle_multiplier"); 160 userSettings.ClientThrottleMultipler = config.GetFloat("client_throttle_multiplier");
161 if (config.Contains("client_socket_rcvbuf_size"))
162 m_clientSocketReceiveBuffer = config.GetInt("client_socket_rcvbuf_size");
160 } 163 }
161 164
162 m_log.DebugFormat("[CLIENT]: client_throttle_multiplier = {0}", userSettings.ClientThrottleMultipler); 165 m_log.DebugFormat("[CLIENT]: client_throttle_multiplier = {0}", userSettings.ClientThrottleMultipler);
@@ -188,47 +191,54 @@ namespace OpenSim.Region.ClientStack.LindenUDP
188 Packet packet = null; 191 Packet packet = null;
189 int numBytes = 1; 192 int numBytes = 1;
190 EndPoint epSender = new IPEndPoint(IPAddress.Any, 0); 193 EndPoint epSender = new IPEndPoint(IPAddress.Any, 0);
194 EndPoint epProxy = null;
191 195
192 if (EndReceive(out numBytes, result, ref epSender)) 196 try
193 { 197 {
194 // Make sure we are getting zeroes when running off the 198 if (EndReceive(out numBytes, result, ref epSender))
195 // end of grab / degrab packets from old clients
196 Array.Clear(RecvBuffer, numBytes, RecvBuffer.Length - numBytes);
197
198 int packetEnd = numBytes - 1;
199 if (proxyPortOffset != 0) packetEnd -= 6;
200
201 try
202 {
203 packet = PacketPool.Instance.GetPacket(RecvBuffer, ref packetEnd, ZeroBuffer);
204 }
205 catch (MalformedDataException e)
206 {
207 m_log.DebugFormat("[CLIENT]: Dropped Malformed Packet due to MalformedDataException: {0}", e.StackTrace);
208 }
209 catch (IndexOutOfRangeException e)
210 { 199 {
211 m_log.DebugFormat("[CLIENT]: Dropped Malformed Packet due to IndexOutOfRangeException: {0}", e.StackTrace); 200 // Make sure we are getting zeroes when running off the
212 } 201 // end of grab / degrab packets from old clients
213 catch (Exception e) 202 Array.Clear(RecvBuffer, numBytes, RecvBuffer.Length - numBytes);
214 { 203
215 m_log.Debug("[CLIENT]: " + e); 204 int packetEnd = numBytes - 1;
216 } 205 if (proxyPortOffset != 0) packetEnd -= 6;
217 } 206
207 try
208 {
209 packet = PacketPool.Instance.GetPacket(RecvBuffer, ref packetEnd, ZeroBuffer);
210 }
211 catch (MalformedDataException e)
212 {
213 m_log.DebugFormat("[CLIENT]: Dropped Malformed Packet due to MalformedDataException: {0}", e.StackTrace);
214 }
215 catch (IndexOutOfRangeException e)
216 {
217 m_log.DebugFormat("[CLIENT]: Dropped Malformed Packet due to IndexOutOfRangeException: {0}", e.StackTrace);
218 }
219 catch (Exception e)
220 {
221 m_log.Debug("[CLIENT]: " + e);
222 }
223 }
218 224
219 EndPoint epProxy = null; 225
220 226 if (proxyPortOffset != 0)
221 if (proxyPortOffset != 0)
222 {
223 // If we've received a use circuit packet, then we need to decode an endpoint proxy, if one exists,
224 // before allowing the RecvBuffer to be overwritten by the next packet.
225 if (packet != null && packet.Type == PacketType.UseCircuitCode)
226 { 227 {
227 epProxy = epSender; 228 // If we've received a use circuit packet, then we need to decode an endpoint proxy, if one exists,
229 // before allowing the RecvBuffer to be overwritten by the next packet.
230 if (packet != null && packet.Type == PacketType.UseCircuitCode)
231 {
232 epProxy = epSender;
233 }
234
235 // Now decode the message from the proxy server
236 epSender = ProxyCodec.DecodeProxyMessage(RecvBuffer, ref numBytes);
228 } 237 }
229 238 }
230 // Now decode the message from the proxy server 239 catch (Exception ex)
231 epSender = ProxyCodec.DecodeProxyMessage(RecvBuffer, ref numBytes); 240 {
241 m_log.ErrorFormat("[CLIENT]: Exception thrown during EndReceive(): {0}", ex);
232 } 242 }
233 243
234 BeginRobustReceive(); 244 BeginRobustReceive();
@@ -324,6 +334,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
324 334
325 done = true; 335 done = true;
326 } 336 }
337 catch (Exception ex)
338 {
339 m_log.ErrorFormat("[CLIENT]: Exception thrown during BeginReceive(): {0}", ex);
340 }
327 } 341 }
328 } 342 }
329 343
@@ -472,6 +486,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
472 486
473 ServerIncoming = new IPEndPoint(listenIP, (int)newPort); 487 ServerIncoming = new IPEndPoint(listenIP, (int)newPort);
474 m_socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); 488 m_socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
489 if (0 != m_clientSocketReceiveBuffer)
490 m_socket.ReceiveBufferSize = m_clientSocketReceiveBuffer;
475 m_socket.Bind(ServerIncoming); 491 m_socket.Bind(ServerIncoming);
476 // Add flags to the UDP socket to prevent "Socket forcibly closed by host" 492 // Add flags to the UDP socket to prevent "Socket forcibly closed by host"
477 // uint IOC_IN = 0x80000000; 493 // uint IOC_IN = 0x80000000;
diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example
index 5f2b46a..2d03731 100644
--- a/bin/OpenSim.ini.example
+++ b/bin/OpenSim.ini.example
@@ -354,6 +354,23 @@
354 ; Pre r7113, this setting was not exposed but was effectively 8. You may want to try this if you encounter 354 ; Pre r7113, this setting was not exposed but was effectively 8. You may want to try this if you encounter
355 ; unexpected difficulties 355 ; unexpected difficulties
356 client_throttle_multiplier = 2; 356 client_throttle_multiplier = 2;
357
358 ; the client socket receive buffer size determines how many
359 ; incoming requests we can process; the default on .NET is 8192
360 ; which is about 2 4k-sized UDP datagrams. On mono this is
361 ; whatever the underlying operating system has as default; for
362 ; example, ubuntu 8.04 or SLES11 have about 111k, which is about
363 ; 27 4k-sized UDP datagrams (on linux platforms you can [as root]
364 ; do "sysctl net.core.rmem_default" to find out what your system
365 ; uses a default socket receive buffer size.
366 ;
367 ; client_socket_rcvbuf_size allows you to specify the receive
368 ; buffer size LLUDPServer should use. NOTE: this will be limited
369 ; by the system's settings for the maximum client receive buffer
370 ; size (on linux systems you can set that with "sysctl -w
371 ; net.core.rmem_max=X")
372 ;
373 ; client_socket_rcvbuf_size = 8388608
357 374
358 375
359[Chat] 376[Chat]