Prechádzať zdrojové kódy

Log correct delay when performing TCP retransmit.

Before, the delay was erroneously multiplied by 2 and also did not
take processing delay into account.
whitequark 7 rokov pred
rodič
commit
c0629f769b
1 zmenil súbory, kde vykonal 8 pridanie a 7 odobranie
  1. 8 7
      src/socket/tcp.rs

+ 8 - 7
src/socket/tcp.rs

@@ -201,17 +201,18 @@ impl Retransmit {
         }
     }
 
-    fn commit(&mut self, timestamp: u64) -> bool {
+    fn commit(&mut self, timestamp: u64) -> Option<u64> {
         if self.delay == 0 {
             self.delay      = 100; // ms
             self.resend_at  = timestamp + self.delay;
-            false
+            None
         } else if timestamp >= self.resend_at {
+            let actual_delay = (timestamp - self.resend_at) + self.delay;
             self.resend_at  = timestamp + self.delay;
             self.delay     *= 2;
-            true
+            Some(actual_delay)
         } else {
-            false
+            None
         }
     }
 }
@@ -1109,10 +1110,10 @@ impl<'a> TcpSocket<'a> {
         }
 
         if should_send {
-            if self.retransmit.commit(timestamp) {
-                net_trace!("[{}]{}:{}: retransmit after {}ms",
+            if let Some(actual_delay) = self.retransmit.commit(timestamp) {
+                net_trace!("[{}]{}:{}: retransmitting at t+{}ms ",
                            self.debug_id, self.local_endpoint, self.remote_endpoint,
-                           self.retransmit.delay);
+                           actual_delay);
             }
 
             if self.state != State::SynSent {