From e3c70ce931da18dd23c8c8e8ec42b76a345bf265 Mon Sep 17 00:00:00 2001 From: Brian Somers Date: Sun, 19 Apr 1998 15:24:50 +0000 Subject: [PATCH] Tidy up the use of struct pppTimer. --- usr.sbin/ppp/auth.c | 3 +-- usr.sbin/ppp/bundle.c | 3 +-- usr.sbin/ppp/chat.c | 5 +---- usr.sbin/ppp/datalink.c | 3 +-- usr.sbin/ppp/fsm.c | 7 +++---- usr.sbin/ppp/hdlc.c | 4 +--- usr.sbin/ppp/lqr.c | 3 +-- usr.sbin/ppp/modem.c | 3 +-- usr.sbin/ppp/prompt.c | 3 +-- usr.sbin/ppp/throughput.c | 10 +++++----- 10 files changed, 16 insertions(+), 28 deletions(-) diff --git a/usr.sbin/ppp/auth.c b/usr.sbin/ppp/auth.c index a1954a1b35ef..8421ac6b83ea 100644 --- a/usr.sbin/ppp/auth.c +++ b/usr.sbin/ppp/auth.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: auth.c,v 1.27.2.20 1998/04/07 00:53:18 brian Exp $ + * $Id: auth.c,v 1.27.2.21 1998/04/16 00:25:47 brian Exp $ * * TODO: * o Implement check against with registered IP addresses. @@ -203,7 +203,6 @@ StartAuthChallenge(struct authinfo *authp, struct physical *physical, authp->authtimer.func = AuthTimeout; authp->authtimer.name = "auth"; authp->authtimer.load = authp->cfg.fsmretry * SECTICKS; - authp->authtimer.state = TIMER_STOPPED; authp->authtimer.arg = (void *) authp; authp->retry = 3; authp->id = 1; diff --git a/usr.sbin/ppp/bundle.c b/usr.sbin/ppp/bundle.c index 9c2d782604ef..ac9b19dca1a1 100644 --- a/usr.sbin/ppp/bundle.c +++ b/usr.sbin/ppp/bundle.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: bundle.c,v 1.1.2.52 1998/04/17 22:05:03 brian Exp $ + * $Id: bundle.c,v 1.1.2.53 1998/04/18 23:17:23 brian Exp $ */ #include @@ -906,7 +906,6 @@ bundle_StartIdleTimer(struct bundle *bundle) bundle->idle.timer.func = bundle_IdleTimeout; bundle->idle.timer.name = "idle"; bundle->idle.timer.load = bundle->cfg.idle_timeout * SECTICKS; - bundle->idle.timer.state = TIMER_STOPPED; bundle->idle.timer.arg = bundle; StartTimer(&bundle->idle.timer); bundle->idle.done = time(NULL) + bundle->cfg.idle_timeout; diff --git a/usr.sbin/ppp/chat.c b/usr.sbin/ppp/chat.c index 3bf52062fdb8..469a3ebc97aa 100644 --- a/usr.sbin/ppp/chat.c +++ b/usr.sbin/ppp/chat.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: chat.c,v 1.44.2.23 1998/04/18 01:01:15 brian Exp $ + * $Id: chat.c,v 1.44.2.24 1998/04/18 23:17:24 brian Exp $ */ #include @@ -77,7 +77,6 @@ chat_PauseTimer(void *v) { struct chat *c = (struct chat *)v; StopTimer(&c->pause); - c->pause.state = TIMER_STOPPED; c->pause.load = 0; } @@ -85,7 +84,6 @@ static void chat_Pause(struct chat *c, u_long load) { StopTimer(&c->pause); - c->pause.state = TIMER_STOPPED; c->pause.load += load; c->pause.func = chat_PauseTimer; c->pause.name = "chat pause"; @@ -105,7 +103,6 @@ static void chat_SetTimeout(struct chat *c) { StopTimer(&c->timeout); - c->timeout.state = TIMER_STOPPED; if (c->TimeoutSec > 0) { c->timeout.load = SECTICKS * c->TimeoutSec; c->timeout.func = chat_TimeoutTimer; diff --git a/usr.sbin/ppp/datalink.c b/usr.sbin/ppp/datalink.c index f895243ccb21..4b4d8be4f2dc 100644 --- a/usr.sbin/ppp/datalink.c +++ b/usr.sbin/ppp/datalink.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: datalink.c,v 1.1.2.40 1998/04/18 01:01:19 brian Exp $ + * $Id: datalink.c,v 1.1.2.41 1998/04/18 23:17:25 brian Exp $ */ #include @@ -85,7 +85,6 @@ datalink_StartDialTimer(struct datalink *dl, int Timeout) StopTimer(&dl->dial_timer); if (Timeout) { - dl->dial_timer.state = TIMER_STOPPED; if (Timeout > 0) dl->dial_timer.load = Timeout * SECTICKS; else diff --git a/usr.sbin/ppp/fsm.c b/usr.sbin/ppp/fsm.c index 316ec9fc7ec9..8b660c1c09c8 100644 --- a/usr.sbin/ppp/fsm.c +++ b/usr.sbin/ppp/fsm.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: fsm.c,v 1.27.2.27 1998/04/07 00:53:41 brian Exp $ + * $Id: fsm.c,v 1.27.2.28 1998/04/16 00:25:58 brian Exp $ * * TODO: */ @@ -163,7 +163,7 @@ NewState(struct fsm * fp, int new) if ((new >= ST_INITIAL && new <= ST_STOPPED) || (new == ST_OPENED)) { StopTimer(&fp->FsmTimer); if (new == ST_STOPPED && fp->StoppedTimer.load) { - fp->StoppedTimer.state = TIMER_STOPPED; + StopTimer(&fp->StoppedTimer); fp->StoppedTimer.func = StoppedTimeout; fp->StoppedTimer.arg = (void *) fp; StartTimer(&fp->StoppedTimer); @@ -235,7 +235,7 @@ FsmOpen(struct fsm * fp) LogPrintf(LogPHASE, "Entering STOPPED state for %d seconds\n", fp->open_mode); NewState(fp, ST_STOPPED); - fp->OpenTimer.state = TIMER_STOPPED; + StopTimer(&fp->OpenTimer); fp->OpenTimer.load = fp->open_mode * SECTICKS; fp->OpenTimer.func = FsmOpenNow; fp->OpenTimer.arg = (void *)fp; @@ -412,7 +412,6 @@ static void FsmInitRestartCounter(struct fsm * fp) { StopTimer(&fp->FsmTimer); - fp->FsmTimer.state = TIMER_STOPPED; fp->FsmTimer.func = FsmTimeout; fp->FsmTimer.arg = (void *) fp; (*fp->fn->InitRestartCounter)(fp); diff --git a/usr.sbin/ppp/hdlc.c b/usr.sbin/ppp/hdlc.c index 5b860ee545de..181e460dfae5 100644 --- a/usr.sbin/ppp/hdlc.c +++ b/usr.sbin/ppp/hdlc.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: hdlc.c,v 1.28.2.25 1998/04/07 00:53:43 brian Exp $ + * $Id: hdlc.c,v 1.28.2.26 1998/04/18 01:01:22 brian Exp $ * * TODO: */ @@ -593,7 +593,6 @@ hdlc_ReportTime(void *v) struct hdlc *hdlc = (struct hdlc *)v; StopTimer(&hdlc->ReportTimer); - hdlc->ReportTimer.state = TIMER_STOPPED; if (memcmp(&hdlc->laststats, &hdlc->stats, sizeof hdlc->stats)) { LogPrintf(LogPHASE, @@ -612,7 +611,6 @@ void hdlc_StartTimer(struct hdlc *hdlc) { StopTimer(&hdlc->ReportTimer); - hdlc->ReportTimer.state = TIMER_STOPPED; hdlc->ReportTimer.load = 60 * SECTICKS; hdlc->ReportTimer.arg = hdlc; hdlc->ReportTimer.func = hdlc_ReportTime; diff --git a/usr.sbin/ppp/lqr.c b/usr.sbin/ppp/lqr.c index e3c3956eb8b4..69bf0f68ffba 100644 --- a/usr.sbin/ppp/lqr.c +++ b/usr.sbin/ppp/lqr.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: lqr.c,v 1.22.2.23 1998/04/16 00:26:07 brian Exp $ + * $Id: lqr.c,v 1.22.2.24 1998/04/18 01:01:24 brian Exp $ * * o LQR based on RFC1333 * @@ -235,7 +235,6 @@ StartLqm(struct lcp *lcp) LogPrintf(LogLQM, "Will send %s every %d.%02d secs\n", physical->hdlc.lqm.method & LQM_LQR ? "LQR" : "ECHO LQR", lcp->want_lqrperiod / 100, lcp->want_lqrperiod % 100); - physical->hdlc.lqm.timer.state = TIMER_STOPPED; physical->hdlc.lqm.timer.load = lcp->want_lqrperiod * SECTICKS / 100; physical->hdlc.lqm.timer.func = SendLqrReport; physical->hdlc.lqm.timer.name = "lqm"; diff --git a/usr.sbin/ppp/modem.c b/usr.sbin/ppp/modem.c index 6474547c35b9..a719423ab8e1 100644 --- a/usr.sbin/ppp/modem.c +++ b/usr.sbin/ppp/modem.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: modem.c,v 1.77.2.50 1998/04/16 00:26:09 brian Exp $ + * $Id: modem.c,v 1.77.2.51 1998/04/17 22:04:32 brian Exp $ * * TODO: */ @@ -325,7 +325,6 @@ modem_StartTimer(struct bundle *bundle, struct physical *modem) ModemTimer = &modem->link.Timer; StopTimer(ModemTimer); - ModemTimer->state = TIMER_STOPPED; ModemTimer->load = SECTICKS; ModemTimer->func = modem_Timeout; ModemTimer->name = "modem CD"; diff --git a/usr.sbin/ppp/prompt.c b/usr.sbin/ppp/prompt.c index f37304a67836..53bbb07bb293 100644 --- a/usr.sbin/ppp/prompt.c +++ b/usr.sbin/ppp/prompt.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: prompt.c,v 1.1.2.26 1998/04/14 23:17:10 brian Exp $ + * $Id: prompt.c,v 1.1.2.27 1998/04/18 01:01:27 brian Exp $ */ #include @@ -505,7 +505,6 @@ prompt_Continue(struct prompt *p) bgtimer.func = prompt_TimedContinue; bgtimer.name = "prompt bg"; bgtimer.load = SECTICKS; - bgtimer.state = TIMER_STOPPED; bgtimer.arg = p; StartTimer(&bgtimer); } diff --git a/usr.sbin/ppp/throughput.c b/usr.sbin/ppp/throughput.c index 4fa3c99ac6f6..3c877fe2345b 100644 --- a/usr.sbin/ppp/throughput.c +++ b/usr.sbin/ppp/throughput.c @@ -23,12 +23,13 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: throughput.c,v 1.4.4.6 1998/04/10 13:19:23 brian Exp $ + * $Id: throughput.c,v 1.4.4.7 1998/04/16 00:26:18 brian Exp $ */ #include #include +#include #include #include @@ -47,6 +48,7 @@ throughput_init(struct pppThroughput *t) for (f = 0; f < SAMPLE_PERIOD; f++) t->SampleOctets[f] = 0; t->OctetsPerSecond = t->BestOctetsPerSecond = t->nSample = 0; + memset(&t->Timer, '\0', sizeof t->Timer); t->Timer.name = "throughput"; t->uptime = 0; t->rolling = 0; @@ -107,7 +109,6 @@ throughput_sampler(void *v) u_long old; StopTimer(&t->Timer); - t->Timer.state = TIMER_STOPPED; old = t->SampleOctets[t->nSample]; t->SampleOctets[t->nSample] = t->OctetsIn + t->OctetsOut; @@ -123,11 +124,11 @@ throughput_sampler(void *v) void throughput_start(struct pppThroughput *t, const char *name, int rolling) { + StopTimer(&t->Timer); throughput_init(t); t->rolling = rolling ? 1 : 0; time(&t->uptime); if (t->rolling) { - t->Timer.state = TIMER_STOPPED; t->Timer.load = SECTICKS; t->Timer.func = throughput_sampler; t->Timer.name = name; @@ -139,8 +140,7 @@ throughput_start(struct pppThroughput *t, const char *name, int rolling) void throughput_stop(struct pppThroughput *t) { - if (t->rolling) - StopTimer(&t->Timer); + StopTimer(&t->Timer); } void