summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authorbrian <brian@FreeBSD.org>1999-08-06 01:34:03 +0000
committerbrian <brian@FreeBSD.org>1999-08-06 01:34:03 +0000
commitc30dbdad409cd53e92bf96fd3ea9a6f32a7cb0d1 (patch)
treea3b7e7ca71742bf1d7a8a6cb7194c497c6432247 /usr.sbin
parente5383f7b660af042d37cfe129a2ef515dce8722e (diff)
downloadFreeBSD-src-c30dbdad409cd53e92bf96fd3ea9a6f32a7cb0d1.zip
FreeBSD-src-c30dbdad409cd53e92bf96fd3ea9a6f32a7cb0d1.tar.gz
If the clock is put back, ensure that we don't end up dividing by
zero when calculating our throughput
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/ppp/throughput.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/usr.sbin/ppp/throughput.c b/usr.sbin/ppp/throughput.c
index dd1b24f..af3b09a 100644
--- a/usr.sbin/ppp/throughput.c
+++ b/usr.sbin/ppp/throughput.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: throughput.c,v 1.9 1999/05/08 11:07:47 brian Exp $
+ * $Id: throughput.c,v 1.10 1999/08/05 10:32:15 brian Exp $
*/
#include <sys/types.h>
@@ -75,6 +75,15 @@ throughput_uptime(struct pppThroughput *t)
time_t downat;
downat = t->downtime ? t->downtime : time(NULL);
+ if (t->uptime && downat < t->uptime) {
+ /* Euch ! The clock's gone back ! */
+ int i;
+
+ for (i = 0; i < t->SamplePeriod; i++)
+ t->SampleOctets[i] = 0;
+ t->nSample = 0;
+ t->uptime = downat;
+ }
return t->uptime ? downat - t->uptime : 0;
}
OpenPOWER on IntegriCloud