From 2222172afaa97a8550c08c32cab3474d37fcf984 Mon Sep 17 00:00:00 2001
From: John Hurliman
Date: Mon, 26 Oct 2009 11:28:02 -0700
Subject: Removed an unnecessary lock in LLUDPClient.UpdateRTO() and
LLUDPClient.BackoffRTO()
---
.../Region/ClientStack/LindenUDP/LLUDPClient.cs | 51 +++++++++-------------
1 file changed, 21 insertions(+), 30 deletions(-)
(limited to 'OpenSim/Region/ClientStack')
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs
index 0948e1c..a823f3b 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs
@@ -144,9 +144,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
private readonly OutgoingPacket[] m_nextPackets = new OutgoingPacket[THROTTLE_CATEGORY_COUNT];
/// A reference to the LLUDPServer that is managing this client
private readonly LLUDPServer m_udpServer;
- /// Locks access to the variables used while calculating round-trip
- /// packet times and the retransmission timeout
- private readonly object m_roundTripCalcLock = new object();
///
/// Default constructor
@@ -487,28 +484,25 @@ namespace OpenSim.Region.ClientStack.LindenUDP
const float BETA = 0.25f;
const float K = 4.0f;
- lock (m_roundTripCalcLock)
+ if (RTTVAR == 0.0f)
{
- if (RTTVAR == 0.0f)
- {
- // First RTT measurement
- SRTT = r;
- RTTVAR = r * 0.5f;
- }
- else
- {
- // Subsequence RTT measurement
- RTTVAR = (1.0f - BETA) * RTTVAR + BETA * Math.Abs(SRTT - r);
- SRTT = (1.0f - ALPHA) * SRTT + ALPHA * r;
- }
+ // First RTT measurement
+ SRTT = r;
+ RTTVAR = r * 0.5f;
+ }
+ else
+ {
+ // Subsequence RTT measurement
+ RTTVAR = (1.0f - BETA) * RTTVAR + BETA * Math.Abs(SRTT - r);
+ SRTT = (1.0f - ALPHA) * SRTT + ALPHA * r;
+ }
- int rto = (int)(SRTT + Math.Max(m_udpServer.TickCountResolution, K * RTTVAR));
+ int rto = (int)(SRTT + Math.Max(m_udpServer.TickCountResolution, K * RTTVAR));
- // Clamp the retransmission timeout to manageable values
- rto = Utils.Clamp(RTO, 3000, 60000);
+ // Clamp the retransmission timeout to manageable values
+ rto = Utils.Clamp(RTO, 3000, 60000);
- RTO = rto;
- }
+ RTO = rto;
//m_log.Debug("[LLUDPCLIENT]: Setting agent " + this.Agent.FullName + "'s RTO to " + RTO + "ms with an RTTVAR of " +
// RTTVAR + " based on new RTT of " + r + "ms");
@@ -520,16 +514,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
///
public void BackoffRTO()
{
- lock (m_roundTripCalcLock)
- {
- // Reset SRTT and RTTVAR, we assume they are bogus since things
- // didn't work out and we're backing off the timeout
- SRTT = 0.0f;
- RTTVAR = 0.0f;
+ // Reset SRTT and RTTVAR, we assume they are bogus since things
+ // didn't work out and we're backing off the timeout
+ SRTT = 0.0f;
+ RTTVAR = 0.0f;
- // Double the retransmission timeout
- RTO = Math.Min(RTO * 2, 60000);
- }
+ // Double the retransmission timeout
+ RTO = Math.Min(RTO * 2, 60000);
}
///
--
cgit v1.1