diff options
author | brian <brian@FreeBSD.org> | 1997-06-09 03:27:43 +0000 |
---|---|---|
committer | brian <brian@FreeBSD.org> | 1997-06-09 03:27:43 +0000 |
commit | 94d661ac8cb907e0a869759f76cd7134c9105e6c (patch) | |
tree | 5fa88c28cbdec0d4a0d3d118b33c1042dc49c526 /usr.sbin/ppp/timer.c | |
parent | 328d28c6502cfec45b8ead98e18b2d8638499efb (diff) | |
download | FreeBSD-src-94d661ac8cb907e0a869759f76cd7134c9105e6c.zip FreeBSD-src-94d661ac8cb907e0a869759f76cd7134c9105e6c.tar.gz |
Overhaul ppp:
o Use syslog
o Remove references to stdout/stderr (incl perror())
o Introduce VarTerm - the interactive terminal or zero
o Allow "set timeout" to affect current session
o Change "set debug" to "set log"
o Allow "set log [+|-]flag"
o Make MSEXT and PASSWDAUTH stuff the default
o Move all #ifdef DEBUG stuff into the code - this
shouldn't be too much overhead. It's now controlled
with "set log +debug"
o Add "set log command, debug, tun, warn, error, alert"
o Remove cdefs.h, and assume an ansi compiler.
o Improve all diagnostic output
o Don't trap SIGSEGV
o SIGHUP now terminates again (log files are controlled
by syslog)
o Call CloseModem() when changing devices
o Fix parsing of third arg of "delete"
I think this fixes the "magic is same" problems that some
people have been experiencing.
The man page is being rewritten. It'll follow soon.
Diffstat (limited to 'usr.sbin/ppp/timer.c')
-rw-r--r-- | usr.sbin/ppp/timer.c | 58 |
1 files changed, 23 insertions, 35 deletions
diff --git a/usr.sbin/ppp/timer.c b/usr.sbin/ppp/timer.c index fbc46d9..00eaa49 100644 --- a/usr.sbin/ppp/timer.c +++ b/usr.sbin/ppp/timer.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: timer.c,v 1.15 1997/05/09 20:48:21 brian Exp $ + * $Id: timer.c,v 1.16 1997/05/10 01:22:19 brian Exp $ * * TODO: */ @@ -31,7 +31,6 @@ #include "sig.h" void StopTimerNoBlock( struct pppTimer *); -void ShowTimers(void); void StopTimer( struct pppTimer *tp ) @@ -45,6 +44,7 @@ StopTimer( struct pppTimer *tp ) sigsetmask(omask); #endif } + void StartTimer(tp) struct pppTimer *tp; @@ -61,17 +61,14 @@ struct pppTimer *tp; StopTimerNoBlock(tp); } if (tp->load == 0) { -#ifdef DEBUG - logprintf("timer %x has 0 load!\n", tp); -#endif + LogPrintf(LogDEBUG, "timer %x has 0 load!\n", tp); sigsetmask(omask); return; } pt = NULL; for (t = TimerList; t; t = t->next) { -#ifdef DEBUG - logprintf("StartTimer: %x(%d): ticks: %d, rest: %d\n", t, t->state, ticks, t->rest); -#endif + LogPrintf(LogDEBUG, "StartTimer: %x(%d): ticks: %d, rest: %d\n", + t, t->state, ticks, t->rest); if (ticks + t->rest >= tp->load) break; ticks += t->rest; @@ -80,9 +77,8 @@ struct pppTimer *tp; tp->state = TIMER_RUNNING; tp->rest = tp->load - ticks; -#ifdef DEBUG - logprintf("Inserting %x before %x, rest = %d\n", tp, t, tp->rest); -#endif + LogPrintf(LogDEBUG, "StartTimer: Inserting %x before %x, rest = %d\n", + tp, t, tp->rest); /* Insert given *tp just before *t */ tp->next = t; if (pt) { @@ -111,9 +107,8 @@ struct pppTimer *tp; * So just marked as TIMER_STOPPED. * Do not change tp->enext!! (Might be Called by expired proc) */ -#ifdef DEBUG - logprintf("StopTimer: %x, next = %x state=%x\n", tp, tp->next, tp->state); -#endif + LogPrintf(LogDEBUG, "StopTimer: %x, next = %x state=%x\n", + tp, tp->next, tp->state); if (tp->state != TIMER_RUNNING) { tp->next = NULL; tp->state = TIMER_STOPPED; @@ -133,9 +128,9 @@ struct pppTimer *tp; } if (t->next) t->next->rest += tp->rest; - } else { - logprintf("Oops, timer not found!!\n"); - } + } else + LogPrintf(LogERROR, "Oops, timer not found!!\n"); + tp->next = NULL; tp->state = TIMER_STOPPED; } @@ -145,9 +140,8 @@ TimerService() { struct pppTimer *tp, *exp, *wt; -#ifdef DEBUG - ShowTimers(); -#endif + if (LogIsKept(LogDEBUG)) + ShowTimers(); tp = TimerList; if (tp) { tp->rest--; @@ -161,19 +155,15 @@ TimerService() wt = tp->next; tp->enext = exp; exp = tp; -#ifdef DEBUG - logprintf("Add %x to exp\n", tp); -#endif + LogPrintf(LogDEBUG, "TimerService: Add %x to exp\n", tp); tp = wt; } while (tp && (tp->rest == 0)); TimerList = tp; if ( TimerList == NULL ) /* No timers ? */ TermTimerService(); /* Terminate Timer Service */ -#ifdef DEBUG - logprintf("TimerService: next is %x(%d)\n", + LogPrintf(LogDEBUG, "TimerService: next is %x(%d)\n", TimerList, TimerList? TimerList->rest : 0); -#endif /* * Process all expired timers. */ @@ -199,11 +189,11 @@ ShowTimers() { struct pppTimer *pt; - logprintf("---- Begin of Timer Service List---\n"); + LogPrintf(LogDEBUG, "---- Begin of Timer Service List---\n"); for (pt = TimerList; pt; pt = pt->next) - logprintf("%x: load = %d, rest = %d, state =%x\n", + LogPrintf(LogDEBUG, "%x: load = %d, rest = %d, state =%x\n", pt, pt->load, pt->rest, pt->state); - logprintf("---- End of Timer Service List ---\n"); + LogPrintf(LogDEBUG, "---- End of Timer Service List ---\n"); } #ifdef SIGALRM @@ -274,9 +264,8 @@ void InitTimerService( void ) { pending_signal(SIGALRM, (void (*)(int))TimerService); itimer.it_interval.tv_sec = itimer.it_value.tv_sec = 0; itimer.it_interval.tv_usec = itimer.it_value.tv_usec = TICKUNIT; - if (setitimer(ITIMER_REAL, &itimer, NULL) == -1) { - logprintf("Unable to set itimer.\n"); - } + if (setitimer(ITIMER_REAL, &itimer, NULL) == -1) + LogPrintf(LogERROR, "Unable to set itimer.\n"); } void TermTimerService( void ) { @@ -284,9 +273,8 @@ void TermTimerService( void ) { itimer.it_interval.tv_usec = itimer.it_interval.tv_sec = 0; itimer.it_value.tv_usec = itimer.it_value.tv_sec = 0; - if (setitimer(ITIMER_REAL, &itimer, NULL) == -1) { - logprintf("Unable to set itimer.\n"); - } + if (setitimer(ITIMER_REAL, &itimer, NULL) == -1) + LogPrintf(LogERROR, "Unable to set itimer.\n"); pending_signal(SIGALRM, SIG_IGN); } #endif |