prevent rx peer timeout from reaching 0.0 seconds
authorJeffrey Altman <jaltman@secure-endpoints.com>
Tue, 20 Oct 2009 20:16:47 +0000 (16:16 -0400)
committerDerrick Brashear <shadow|account-1000005@unknown>
Tue, 20 Oct 2009 20:54:19 +0000 (13:54 -0700)
The rx peer timeout is computed from the round trip time
calculation.  It traditionally has had a lowerbound of 350ms.
The computation in rxi_ComputeRoundTripTime() was incorrect
and instead used 350ms as an upperbound.

rxi_ComputeRoundTripTime() had a second problem wherein if
the actually RTT is shorter than the resolution of the clock
then the RTT would quickly approach 0.0 seconds.  Enforce
a lowerbound of 1ms if the RTT for a given packet appears
to be 0.0 seconds.

LICENSE BSD

Reviewed-on: http://gerrit.openafs.org/696
Tested-by: Jeffrey Altman <jaltman@openafs.org>
Reviewed-by: Jeffrey Altman <jaltman@openafs.org>
Tested-by: Derrick Brashear <shadow@dementia.org>
Reviewed-by: Derrick Brashear <shadow@dementia.org>

src/rx/rx.c

index 36ee1e3..c7d4ad7 100755 (executable)
@@ -5988,6 +5988,16 @@ rxi_ComputeRoundTripTime(struct rx_packet *p,
     clock_Sub(rttp, sentp);
     dpf(("rxi_ComputeRoundTripTime(call=%d packet=%"AFS_PTR_FMT" rttp=%d.%06d sec)\n",
           p->header.callNumber, p, rttp->sec, rttp->usec));
+
+    if (rttp->sec == 0 && rttp->usec == 0) {
+        /*
+         * The actual round trip time is shorter than the
+         * clock_GetTime resolution.  It is most likely 1ms or 100ns.
+         * Since we can't tell which at the moment we will assume 1ms.
+         */
+        rttp->usec = 1000;
+    }
+
     if (rx_stats_active) {
         MUTEX_ENTER(&rx_stats_mutex);
         if (clock_Lt(rttp, &rx_stats.minRtt))
@@ -6063,7 +6073,7 @@ rxi_ComputeRoundTripTime(struct rx_packet *p,
      * be switched and/or swapped out.  So on fast, reliable networks, the
      * timeout would otherwise be too short.  
      */
-    rtt_timeout = MIN((peer->rtt >> 3) + peer->rtt_dev, 350);
+    rtt_timeout = MAX(((peer->rtt >> 3) + peer->rtt_dev), 350);
     clock_Zero(&(peer->timeout));
     clock_Addmsec(&(peer->timeout), rtt_timeout);