aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs')
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs82
1 files changed, 41 insertions, 41 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs b/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs
index 831381e..35a0711 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs
@@ -3,25 +3,25 @@
3 * Original Author: Jeff Cesnik 3 * Original Author: Jeff Cesnik
4 * All rights reserved. 4 * All rights reserved.
5 * 5 *
6 * - Redistribution and use in source and binary forms, with or without 6 * - Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met: 7 * modification, are permitted provided that the following conditions are met:
8 * 8 *
9 * - Redistributions of source code must retain the above copyright notice, this 9 * - Redistributions of source code must retain the above copyright notice, this
10 * list of conditions and the following disclaimer. 10 * list of conditions and the following disclaimer.
11 * - Neither the name of the openmetaverse.org nor the names 11 * - Neither the name of the openmetaverse.org nor the names
12 * of its contributors may be used to endorse or promote products derived from 12 * of its contributors may be used to endorse or promote products derived from
13 * this software without specific prior written permission. 13 * this software without specific prior written permission.
14 * 14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE. 25 * POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
@@ -107,10 +107,10 @@ namespace OpenMetaverse
107 /// </summary> 107 /// </summary>
108 public float AverageReceiveTicksForLastSamplePeriod { get; private set; } 108 public float AverageReceiveTicksForLastSamplePeriod { get; private set; }
109 109
110 public int Port 110 public int Port
111 { 111 {
112 get { return m_udpPort; } 112 get { return m_udpPort; }
113 } 113 }
114 114
115 #region PacketDropDebugging 115 #region PacketDropDebugging
116 /// <summary> 116 /// <summary>
@@ -118,7 +118,7 @@ namespace OpenMetaverse
118 /// outbound packets. 118 /// outbound packets.
119 /// </summary> 119 /// </summary>
120 private Random m_dropRandomGenerator = new Random(); 120 private Random m_dropRandomGenerator = new Random();
121 121
122 /// <summary> 122 /// <summary>
123 /// For debugging purposes only... parameters for a simplified 123 /// For debugging purposes only... parameters for a simplified
124 /// model of packet loss with bursts, overall drop rate should 124 /// model of packet loss with bursts, overall drop rate should
@@ -137,7 +137,7 @@ namespace OpenMetaverse
137 /// </summary> 137 /// </summary>
138 private int m_dropLastTick = 0; 138 private int m_dropLastTick = 0;
139 private int m_dropResetTicks = 500; 139 private int m_dropResetTicks = 500;
140 140
141 /// <summary> 141 /// <summary>
142 /// Debugging code used to simulate dropped packets with bursts 142 /// Debugging code used to simulate dropped packets with bursts
143 /// </summary> 143 /// </summary>
@@ -187,13 +187,13 @@ namespace OpenMetaverse
187 ~OpenSimUDPBase() 187 ~OpenSimUDPBase()
188 { 188 {
189 if(m_udpSocket !=null) 189 if(m_udpSocket !=null)
190 try { m_udpSocket.Close(); } catch { } 190 try { m_udpSocket.Close(); } catch { }
191 } 191 }
192 /// <summary> 192 /// <summary>
193 /// Start inbound UDP packet handling. 193 /// Start inbound UDP packet handling.
194 /// </summary> 194 /// </summary>
195 /// <param name="recvBufferSize">The size of the receive buffer for 195 /// <param name="recvBufferSize">The size of the receive buffer for
196 /// the UDP socket. This value is passed up to the operating system 196 /// the UDP socket. This value is passed up to the operating system
197 /// and used in the system networking stack. Use zero to leave this 197 /// and used in the system networking stack. Use zero to leave this
198 /// value as the default</param> 198 /// value as the default</param>
199 /// <param name="asyncPacketHandling">Set this to true to start 199 /// <param name="asyncPacketHandling">Set this to true to start
@@ -235,7 +235,7 @@ namespace OpenMetaverse
235 } 235 }
236 try 236 try
237 { 237 {
238 // This udp socket flag is not supported under mono, 238 // This udp socket flag is not supported under mono,
239 // so we'll catch the exception and continue 239 // so we'll catch the exception and continue
240 m_udpSocket.IOControl(SIO_UDP_CONNRESET, new byte[] { 0 }, null); 240 m_udpSocket.IOControl(SIO_UDP_CONNRESET, new byte[] { 0 }, null);
241 m_log.Debug("[UDPBASE]: SIO_UDP_CONNRESET flag set"); 241 m_log.Debug("[UDPBASE]: SIO_UDP_CONNRESET flag set");
@@ -249,12 +249,12 @@ namespace OpenMetaverse
249 // we never want two regions to listen on the same port as they cannot demultiplex each other's messages, 249 // we never want two regions to listen on the same port as they cannot demultiplex each other's messages,
250 // leading to a confusing bug. 250 // leading to a confusing bug.
251 // By default, Windows does not allow two sockets to bind to the same port. 251 // By default, Windows does not allow two sockets to bind to the same port.
252 // 252 //
253 // Unfortunately, this also causes a crashed sim to leave the socket in a state 253 // Unfortunately, this also causes a crashed sim to leave the socket in a state
254 // where it appears to be in use but is really just hung from the old process 254 // where it appears to be in use but is really just hung from the old process
255 // crashing rather than closing it. While this protects agains misconfiguration, 255 // crashing rather than closing it. While this protects agains misconfiguration,
256 // allowing crashed sims to be started up again right away, rather than having to 256 // allowing crashed sims to be started up again right away, rather than having to
257 // wait 2 minutes for the socket to clear is more valuable. Commented 12/13/2016 257 // wait 2 minutes for the socket to clear is more valuable. Commented 12/13/2016
258 // m_udpSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, false); 258 // m_udpSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, false);
259 259
260 if (recvBufferSize != 0) 260 if (recvBufferSize != 0)
@@ -262,8 +262,8 @@ namespace OpenMetaverse
262 262
263 m_udpSocket.Bind(ipep); 263 m_udpSocket.Bind(ipep);
264 264
265 if (m_udpPort == 0) 265 if (m_udpPort == 0)
266 m_udpPort = ((IPEndPoint)m_udpSocket.LocalEndPoint).Port; 266 m_udpPort = ((IPEndPoint)m_udpSocket.LocalEndPoint).Port;
267 267
268 IsRunningInbound = true; 268 IsRunningInbound = true;
269 269
@@ -334,7 +334,7 @@ namespace OpenMetaverse
334 { 334 {
335 UDPPacketBuffer buf; 335 UDPPacketBuffer buf;
336 336
337 // FIXME: Disabled for now as this causes issues with reused packet objects interfering with each other 337 // FIXME: Disabled for now as this causes issues with reused packet objects interfering with each other
338 // on Windows with m_asyncPacketHandling = true, though this has not been seen on Linux. 338 // on Windows with m_asyncPacketHandling = true, though this has not been seen on Linux.
339 // Possibly some unexpected issue with fetching UDP data concurrently with multiple threads. Requires more investigation. 339 // Possibly some unexpected issue with fetching UDP data concurrently with multiple threads. Requires more investigation.
340// if (UsePools) 340// if (UsePools)
@@ -387,8 +387,8 @@ namespace OpenMetaverse
387 m_log.Warn("[UDPBASE]: Salvaged the UDP listener on port " + m_udpPort); 387 m_log.Warn("[UDPBASE]: Salvaged the UDP listener on port " + m_udpPort);
388 } 388 }
389 } 389 }
390 catch (ObjectDisposedException e) 390 catch (ObjectDisposedException e)
391 { 391 {
392 m_log.Error( 392 m_log.Error(
393 string.Format("[UDPBASE]: Error processing UDP begin receive {0}. Exception ", UdpReceives), e); 393 string.Format("[UDPBASE]: Error processing UDP begin receive {0}. Exception ", UdpReceives), e);
394 } 394 }
@@ -434,7 +434,7 @@ namespace OpenMetaverse
434 // since this should be rare and won't cause a runtime problem. 434 // since this should be rare and won't cause a runtime problem.
435 if (m_currentReceiveTimeSamples >= s_receiveTimeSamples) 435 if (m_currentReceiveTimeSamples >= s_receiveTimeSamples)
436 { 436 {
437 AverageReceiveTicksForLastSamplePeriod 437 AverageReceiveTicksForLastSamplePeriod
438 = (float)m_receiveTicksInCurrentSamplePeriod / s_receiveTimeSamples; 438 = (float)m_receiveTicksInCurrentSamplePeriod / s_receiveTimeSamples;
439 439
440 m_receiveTicksInCurrentSamplePeriod = 0; 440 m_receiveTicksInCurrentSamplePeriod = 0;
@@ -446,16 +446,16 @@ namespace OpenMetaverse
446 m_currentReceiveTimeSamples++; 446 m_currentReceiveTimeSamples++;
447 } 447 }
448 } 448 }
449 catch (SocketException se) 449 catch (SocketException se)
450 { 450 {
451 m_log.Error( 451 m_log.Error(
452 string.Format( 452 string.Format(
453 "[UDPBASE]: Error processing UDP end receive {0}, socket error code {1}. Exception ", 453 "[UDPBASE]: Error processing UDP end receive {0}, socket error code {1}. Exception ",
454 UdpReceives, se.ErrorCode), 454 UdpReceives, se.ErrorCode),
455 se); 455 se);
456 } 456 }
457 catch (ObjectDisposedException e) 457 catch (ObjectDisposedException e)
458 { 458 {
459 m_log.Error( 459 m_log.Error(
460 string.Format("[UDPBASE]: Error processing UDP end receive {0}. Exception ", UdpReceives), e); 460 string.Format("[UDPBASE]: Error processing UDP end receive {0}. Exception ", UdpReceives), e);
461 } 461 }
@@ -486,7 +486,7 @@ namespace OpenMetaverse
486 // packets when testing throttles & retransmission code 486 // packets when testing throttles & retransmission code
487 // if (DropOutgoingPacket()) 487 // if (DropOutgoingPacket())
488 // return; 488 // return;
489 489
490 try 490 try
491 { 491 {
492 m_udpSocket.BeginSendTo( 492 m_udpSocket.BeginSendTo(