From f97d860db9f98605e5db9ad5a3c44cc6868b8590 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Tue, 20 Oct 2009 16:16:47 -0400 Subject: [PATCH] prevent rx peer timeout from reaching 0.0 seconds 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 Change-Id: I83d3a3d64127d4c023df2fce5e45a4df3eb35679 Reviewed-on: http://gerrit.openafs.org/696 Tested-by: Jeffrey Altman Reviewed-by: Jeffrey Altman Tested-by: Derrick Brashear Reviewed-by: Derrick Brashear Reviewed-on: http://gerrit.openafs.org/974 --- src/rx/rx.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/rx/rx.c b/src/rx/rx.c index 812eeab1a..0fdb8ab5a 100644 --- a/src/rx/rx.c +++ b/src/rx/rx.c @@ -5708,6 +5708,15 @@ rxi_ComputeRoundTripTime(register struct rx_packet *p, return; /* somebody set the clock back, don't count this time. */ } clock_Sub(rttp, sentp); + 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; + } + MUTEX_ENTER(&rx_stats_mutex); if (clock_Lt(rttp, &rx_stats.minRtt)) rx_stats.minRtt = *rttp; @@ -5781,7 +5790,7 @@ rxi_ComputeRoundTripTime(register 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); -- 2.39.5