aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJohn Hurliman2009-10-26 11:28:02 -0700
committerJohn Hurliman2009-10-26 11:28:02 -0700
commit2222172afaa97a8550c08c32cab3474d37fcf984 (patch)
treefd55dde249f806d41e99b1ccacc37ba86975cbd3
parentAdded a missing reference to System.Core for OpenSim.Region.Framework (diff)
downloadopensim-SC-2222172afaa97a8550c08c32cab3474d37fcf984.zip
opensim-SC-2222172afaa97a8550c08c32cab3474d37fcf984.tar.gz
opensim-SC-2222172afaa97a8550c08c32cab3474d37fcf984.tar.bz2
opensim-SC-2222172afaa97a8550c08c32cab3474d37fcf984.tar.xz
Removed an unnecessary lock in LLUDPClient.UpdateRTO() and LLUDPClient.BackoffRTO()
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs51
1 files changed, 21 insertions, 30 deletions
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
144 private readonly OutgoingPacket[] m_nextPackets = new OutgoingPacket[THROTTLE_CATEGORY_COUNT]; 144 private readonly OutgoingPacket[] m_nextPackets = new OutgoingPacket[THROTTLE_CATEGORY_COUNT];
145 /// <summary>A reference to the LLUDPServer that is managing this client</summary> 145 /// <summary>A reference to the LLUDPServer that is managing this client</summary>
146 private readonly LLUDPServer m_udpServer; 146 private readonly LLUDPServer m_udpServer;
147 /// <summary>Locks access to the variables used while calculating round-trip
148 /// packet times and the retransmission timeout</summary>
149 private readonly object m_roundTripCalcLock = new object();
150 147
151 /// <summary> 148 /// <summary>
152 /// Default constructor 149 /// Default constructor
@@ -487,28 +484,25 @@ namespace OpenSim.Region.ClientStack.LindenUDP
487 const float BETA = 0.25f; 484 const float BETA = 0.25f;
488 const float K = 4.0f; 485 const float K = 4.0f;
489 486
490 lock (m_roundTripCalcLock) 487 if (RTTVAR == 0.0f)
491 { 488 {
492 if (RTTVAR == 0.0f) 489 // First RTT measurement
493 { 490 SRTT = r;
494 // First RTT measurement 491 RTTVAR = r * 0.5f;
495 SRTT = r; 492 }
496 RTTVAR = r * 0.5f; 493 else
497 } 494 {
498 else 495 // Subsequence RTT measurement
499 { 496 RTTVAR = (1.0f - BETA) * RTTVAR + BETA * Math.Abs(SRTT - r);
500 // Subsequence RTT measurement 497 SRTT = (1.0f - ALPHA) * SRTT + ALPHA * r;
501 RTTVAR = (1.0f - BETA) * RTTVAR + BETA * Math.Abs(SRTT - r); 498 }
502 SRTT = (1.0f - ALPHA) * SRTT + ALPHA * r;
503 }
504 499
505 int rto = (int)(SRTT + Math.Max(m_udpServer.TickCountResolution, K * RTTVAR)); 500 int rto = (int)(SRTT + Math.Max(m_udpServer.TickCountResolution, K * RTTVAR));
506 501
507 // Clamp the retransmission timeout to manageable values 502 // Clamp the retransmission timeout to manageable values
508 rto = Utils.Clamp(RTO, 3000, 60000); 503 rto = Utils.Clamp(RTO, 3000, 60000);
509 504
510 RTO = rto; 505 RTO = rto;
511 }
512 506
513 //m_log.Debug("[LLUDPCLIENT]: Setting agent " + this.Agent.FullName + "'s RTO to " + RTO + "ms with an RTTVAR of " + 507 //m_log.Debug("[LLUDPCLIENT]: Setting agent " + this.Agent.FullName + "'s RTO to " + RTO + "ms with an RTTVAR of " +
514 // RTTVAR + " based on new RTT of " + r + "ms"); 508 // RTTVAR + " based on new RTT of " + r + "ms");
@@ -520,16 +514,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
520 /// </summary> 514 /// </summary>
521 public void BackoffRTO() 515 public void BackoffRTO()
522 { 516 {
523 lock (m_roundTripCalcLock) 517 // Reset SRTT and RTTVAR, we assume they are bogus since things
524 { 518 // didn't work out and we're backing off the timeout
525 // Reset SRTT and RTTVAR, we assume they are bogus since things 519 SRTT = 0.0f;
526 // didn't work out and we're backing off the timeout 520 RTTVAR = 0.0f;
527 SRTT = 0.0f;
528 RTTVAR = 0.0f;
529 521
530 // Double the retransmission timeout 522 // Double the retransmission timeout
531 RTO = Math.Min(RTO * 2, 60000); 523 RTO = Math.Min(RTO * 2, 60000);
532 }
533 } 524 }
534 525
535 /// <summary> 526 /// <summary>