From 83569b351c4f9868b043e7c48e90d5ba56da9838 Mon Sep 17 00:00:00 2001 From: Brian Somers Date: Fri, 19 Nov 1999 23:21:13 +0000 Subject: [PATCH] Update the time delta of the first item in TimerList before inserting a new item. Without this, it's possible to mis-insert quite badly... but only by as much as the load of the first item, which is almost always 1 second. Initialise the timerservice with `restart' set if we're inserting at the start of the list. --- usr.sbin/ppp/timer.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/usr.sbin/ppp/timer.c b/usr.sbin/ppp/timer.c index a0f039d8707..7a7d592fdfa 100644 --- a/usr.sbin/ppp/timer.c +++ b/usr.sbin/ppp/timer.c @@ -62,6 +62,7 @@ timer_Stop(struct pppTimer *tp) void timer_Start(struct pppTimer *tp) { + struct itimerval itimer; struct pppTimer *t, *pt; u_long ticks = 0; int omask; @@ -76,6 +77,12 @@ timer_Start(struct pppTimer *tp) sigsetmask(omask); return; } + + /* Adjust our first delta so that it reflects what's really happening */ + if (TimerList && getitimer(ITIMER_REAL, &itimer) == 0) + TimerList->rest = itimer.it_value.tv_sec * SECTICKS + + itimer.it_value.tv_usec / TICKUNIT; + pt = NULL; for (t = TimerList; t; t = t->next) { if (ticks + t->rest >= tp->load) @@ -99,7 +106,7 @@ timer_Start(struct pppTimer *tp) pt->next = tp; } else { TimerList = tp; - timer_InitService(0); /* Start the Timer Service */ + timer_InitService(t != NULL); /* [re]Start the Timer Service */ } if (t) t->rest -= tp->rest; -- 2.45.2