diff options
| author | Brian Somers <brian@FreeBSD.org> | 2000-03-21 10:23:20 +0000 |
|---|---|---|
| committer | Brian Somers <brian@FreeBSD.org> | 2000-03-21 10:23:20 +0000 |
| commit | a8f574395cd8235daba4282e257d05aa7c171d80 (patch) | |
| tree | 7d21303815fed699a13209e3f532410d9834072a /usr.sbin/ppp/timer.c | |
| parent | 9fc98f33802cb0d361238409c621a6966c85c294 (diff) | |
Notes
Diffstat (limited to 'usr.sbin/ppp/timer.c')
| -rw-r--r-- | usr.sbin/ppp/timer.c | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/usr.sbin/ppp/timer.c b/usr.sbin/ppp/timer.c index 144c306fa740..9e69aea6e87b 100644 --- a/usr.sbin/ppp/timer.c +++ b/usr.sbin/ppp/timer.c @@ -35,6 +35,11 @@ #include "descriptor.h" #include "prompt.h" + +#define RESTVAL(t) \ + ((t).it_value.tv_sec * SECTICKS + (t).it_value.tv_usec / TICKUNIT + \ + ((((t).it_value.tv_usec % TICKUNIT) >= (TICKUNIT >> 1)) ? 1 : 0)) + static struct pppTimer *TimerList = NULL, *ExpiredList = NULL; static void StopTimerNoBlock(struct pppTimer *); @@ -80,8 +85,7 @@ timer_Start(struct pppTimer *tp) /* 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; + TimerList->rest = RESTVAL(itimer); pt = NULL; for (t = TimerList; t; t = t->next) { @@ -133,15 +137,24 @@ StopTimerNoBlock(struct pppTimer *tp) pt = t; if (t) { - if (pt) { + if (pt) pt->next = t->next; - } else { + else { TimerList = t->next; if (TimerList == NULL) /* Last one ? */ timer_TermService(); /* Terminate Timer Service */ } - if (t->next) - t->next->rest += tp->rest; + if (t->next) { + if (!pt) { /* t (tp) was the first in the list */ + struct itimerval itimer; + + if (getitimer(ITIMER_REAL, &itimer) == 0) + t->rest = RESTVAL(itimer); + } + t->next->rest += t->rest; + if (!pt) /* t->next is now the first in the list */ + timer_InitService(1); + } } else { /* Search for any pending expired timers */ pt = NULL; @@ -215,8 +228,7 @@ timer_Show(int LogLevel, struct prompt *prompt) /* 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; + TimerList->rest = RESTVAL(itimer); #define SECS(val) ((val) / SECTICKS) #define HSECS(val) (((val) % SECTICKS) * 100 / SECTICKS) |
