summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ppp/timer.c
diff options
context:
space:
mode:
authorbrian <brian@FreeBSD.org>1999-05-12 19:10:22 +0000
committerbrian <brian@FreeBSD.org>1999-05-12 19:10:22 +0000
commitdb9107676889c07d1c16c9a8c9c1243295364f6a (patch)
tree2a36efe904dce1b541f947e43edb3aaf39d247d8 /usr.sbin/ppp/timer.c
parent64dd9c44eb9bd681c37af532c223d46fabd02a70 (diff)
downloadFreeBSD-src-db9107676889c07d1c16c9a8c9c1243295364f6a.zip
FreeBSD-src-db9107676889c07d1c16c9a8c9c1243295364f6a.tar.gz
Adjust our first timer delta according to the return
from getitimer() so that times are correct for ``show timer''.
Diffstat (limited to 'usr.sbin/ppp/timer.c')
-rw-r--r--usr.sbin/ppp/timer.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/usr.sbin/ppp/timer.c b/usr.sbin/ppp/timer.c
index 58aa953..759ddc2 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.32 1998/12/14 19:24:29 brian Exp $
+ * $Id: timer.c,v 1.33 1999/05/09 20:02:28 brian Exp $
*
* TODO:
*/
@@ -25,6 +25,7 @@
#include <errno.h>
#include <signal.h>
#include <stdio.h>
+#include <string.h>
#include <sys/time.h>
#include <termios.h>
@@ -189,13 +190,19 @@ TimerService(void)
void
timer_Show(int LogLevel, struct prompt *prompt)
{
+ struct itimerval itimer;
struct pppTimer *pt;
- int rest = 0;
+ u_long rest = 0;
+
+ /* 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;
#define SECS(val) ((val) / SECTICKS)
#define HSECS(val) (((val) % SECTICKS) * 100 / SECTICKS)
#define DISP \
- "%s timer[%p]: freq = %ld.%02lds, next = %d.%02ds, state = %s\n", \
+ "%s timer[%p]: freq = %ld.%02lds, next = %lu.%02lus, state = %s\n", \
pt->name, pt, SECS(pt->load), HSECS(pt->load), SECS(rest), \
HSECS(rest), tState2Nam(pt->state)
@@ -227,7 +234,7 @@ timer_InitService(int restart)
itimer.it_value.tv_sec = TimerList->rest / SECTICKS;
itimer.it_value.tv_usec = (TimerList->rest % SECTICKS) * TICKUNIT;
if (setitimer(ITIMER_REAL, &itimer, NULL) == -1)
- log_Printf(LogERROR, "Unable to set itimer (%s)\n", sys_errlist[errno]);
+ log_Printf(LogERROR, "Unable to set itimer (%s)\n", strerror(errno));
}
}
@@ -239,6 +246,6 @@ timer_TermService(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)
- log_Printf(LogERROR, "Unable to set itimer (%s)\n", sys_errlist[errno]);
+ log_Printf(LogERROR, "Unable to set itimer (%s)\n", strerror(errno));
sig_signal(SIGALRM, SIG_IGN);
}
OpenPOWER on IntegriCloud