summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorbrian <brian@cvs.openbsd.org>1999-08-06 01:34:53 +0000
committerbrian <brian@cvs.openbsd.org>1999-08-06 01:34:53 +0000
commite17b369caea005f55630416e6f6878b009e95526 (patch)
tree18a002ea1b1f42158484013141bb08dd1a7b1f21 /usr.sbin
parent9cb53d306efa5777e6f896b95d20e24c266849bb (diff)
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/ppp/throughput.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/usr.sbin/ppp/ppp/throughput.c b/usr.sbin/ppp/ppp/throughput.c
index 6246298fc4a..c6596800e94 100644
--- a/usr.sbin/ppp/ppp/throughput.c
+++ b/usr.sbin/ppp/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.4 1999/08/05 10:32:14 brian Exp $
+ * $Id: throughput.c,v 1.5 1999/08/06 01:34:52 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;
}