diff options
author | brian <brian@FreeBSD.org> | 1997-01-29 01:27:58 +0000 |
---|---|---|
committer | brian <brian@FreeBSD.org> | 1997-01-29 01:27:58 +0000 |
commit | bfe2c2933595179da4499f68624984a9fee9a316 (patch) | |
tree | c2b48f73447142a2c98b388757bac61aa053b834 /usr.sbin | |
parent | cb0391dcad998534fe857eb5f19f7045fce07949 (diff) | |
download | FreeBSD-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')
-rw-r--r-- | usr.sbin/ppp/main.c | 10 | ||||
-rw-r--r-- | usr.sbin/ppp/timeout.h | 1 | ||||
-rw-r--r-- | usr.sbin/ppp/timer.c | 26 |
3 files changed, 36 insertions, 1 deletions
diff --git a/usr.sbin/ppp/main.c b/usr.sbin/ppp/main.c index e70c110..ac8657f 100644 --- a/usr.sbin/ppp/main.c +++ b/usr.sbin/ppp/main.c @@ -818,12 +818,22 @@ DoLoop() tp = (dial_up && RedialTimer.state != TIMER_RUNNING) ? &timeout : NULL; i = select(tun_in+10, &rfds, &wfds, &efds, tp); #endif + if ( i == 0 ) { continue; } if ( i < 0 ) { if ( errno == EINTR ) { + if( TimerServiceRequest > 0 ) { +#ifdef DEBUG + logprintf( "Invoking TimerService\n" ); +#endif + /* Maybe a bit cautious.... */ + TimerServiceRequest = -1; + TimerService(); + TimerServiceRequest = 0; + } continue; /* Got SIGALRM, Do check a queue for dialing */ } perror("select"); diff --git a/usr.sbin/ppp/timeout.h b/usr.sbin/ppp/timeout.h index 1da38ef..afba12a 100644 --- a/usr.sbin/ppp/timeout.h +++ b/usr.sbin/ppp/timeout.h @@ -42,6 +42,7 @@ struct pppTimer { #define TIMER_EXPIRED 2 struct pppTimer *TimerList; +extern int TimerServiceRequest; /* If this is >0, call TimerService() */ extern void StartTimer __P((struct pppTimer *)); extern void StopTimer __P((struct pppTimer *)); 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); |