summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ppp/timer.c
diff options
context:
space:
mode:
authorbrian <brian@FreeBSD.org>1997-01-29 01:27:58 +0000
committerbrian <brian@FreeBSD.org>1997-01-29 01:27:58 +0000
commitbfe2c2933595179da4499f68624984a9fee9a316 (patch)
treec2b48f73447142a2c98b388757bac61aa053b834 /usr.sbin/ppp/timer.c
parentcb0391dcad998534fe857eb5f19f7045fce07949 (diff)
downloadFreeBSD-src-bfe2c2933595179da4499f68624984a9fee9a316.zip
FreeBSD-src-bfe2c2933595179da4499f68624984a9fee9a316.tar.gz
Move the call to TimerService() into main.c - just after the select()
call. The SIGALRM just sets a flag now, preventing the possibility of any nasty recursivness in the handler itself.
Diffstat (limited to 'usr.sbin/ppp/timer.c')
-rw-r--r--usr.sbin/ppp/timer.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/usr.sbin/ppp/timer.c b/usr.sbin/ppp/timer.c
index be3e80b..b9f0acf 100644
--- a/usr.sbin/ppp/timer.c
+++ b/usr.sbin/ppp/timer.c
@@ -138,6 +138,24 @@ struct pppTimer *tp;
tp->state = TIMER_STOPPED;
}
+/*
+ This is used to decide at the top level if it's time for a TimerService()
+ call. This'll work fine as long as select() is interrupted by the
+ SIGALRM.
+*/
+int TimerServiceRequest = 0;
+
+void
+SetTimerServiceRequest( int Sig )
+{
+ /* Maybe a bit cautious.... */
+ if( TimerServiceRequest >= 0 )
+ TimerServiceRequest++;
+#ifdef DEBUG
+ logprintf( "Setting TimerServiceRequest\n" );
+#endif
+}
+
void
TimerService()
{
@@ -269,7 +287,13 @@ void usleep( u_int usec)
void InitTimerService( void ) {
struct itimerval itimer;
- signal(SIGALRM, (void (*)(int))TimerService);
+ /*
+ Let's not do this - it's a bit dangerous (potential recursion into the
+ likes of malloc() etc.
+
+ signal(SIGALRM, (void (*)(int))TimerService);
+ */
+ signal(SIGALRM, SetTimerServiceRequest);
itimer.it_interval.tv_sec = itimer.it_value.tv_sec = 0;
itimer.it_interval.tv_usec = itimer.it_value.tv_usec = TICKUNIT;
setitimer(ITIMER_REAL, &itimer, NULL);
OpenPOWER on IntegriCloud