diff options
author | brian <brian@FreeBSD.org> | 1999-11-19 23:21:13 +0000 |
---|---|---|
committer | brian <brian@FreeBSD.org> | 1999-11-19 23:21:13 +0000 |
commit | e68cdbf6569a239c7efa463844f7dd47f587706c (patch) | |
tree | 4e77eac5bf83451ce692dad96e3d30490fbca8e6 /usr.sbin/ppp/timer.c | |
parent | 9429fb5919438f8e208059e2b7fd26af87ac2aa4 (diff) | |
download | FreeBSD-src-e68cdbf6569a239c7efa463844f7dd47f587706c.zip FreeBSD-src-e68cdbf6569a239c7efa463844f7dd47f587706c.tar.gz |
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.
Diffstat (limited to 'usr.sbin/ppp/timer.c')
-rw-r--r-- | usr.sbin/ppp/timer.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/usr.sbin/ppp/timer.c b/usr.sbin/ppp/timer.c index a0f039d..7a7d592 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; |