summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ppp/chat.c
diff options
context:
space:
mode:
authorbrian <brian@FreeBSD.org>1999-12-03 06:33:10 +0000
committerbrian <brian@FreeBSD.org>1999-12-03 06:33:10 +0000
commit0646335b2f5f7598da20e77bef0307600e5090c2 (patch)
treee7ed7b5062bdcdb2fd9076a534d57580850d607e /usr.sbin/ppp/chat.c
parent07cba0f9111a977a86c5f79554b6891a7e4f06a4 (diff)
downloadFreeBSD-src-0646335b2f5f7598da20e77bef0307600e5090c2.zip
FreeBSD-src-0646335b2f5f7598da20e77bef0307600e5090c2.tar.gz
Be careful not to re-initialise `struct stat' while it still has
a running timer. This fixes a problem where a dial is manually aborted, the hangup script kicks in and the chat timer ends up on the timer queue twice (tick tick tick tick *boom*)
Diffstat (limited to 'usr.sbin/ppp/chat.c')
-rw-r--r--usr.sbin/ppp/chat.c31
1 files changed, 23 insertions, 8 deletions
diff --git a/usr.sbin/ppp/chat.c b/usr.sbin/ppp/chat.c
index f3bc7d6..0ccda30 100644
--- a/usr.sbin/ppp/chat.c
+++ b/usr.sbin/ppp/chat.c
@@ -531,8 +531,7 @@ chat_Write(struct descriptor *d, struct bundle *bundle, const fd_set *fdset)
}
void
-chat_Init(struct chat *c, struct physical *p, const char *data,
- const char *phone)
+chat_Init(struct chat *c, struct physical *p)
{
c->desc.type = CHAT_DESCRIPTOR;
c->desc.UpdateSet = chat_UpdateSet;
@@ -540,7 +539,20 @@ chat_Init(struct chat *c, struct physical *p, const char *data,
c->desc.Read = chat_Read;
c->desc.Write = chat_Write;
c->physical = p;
+ *c->script = '\0';
+ c->argc = 0;
+ c->arg = -1;
+ c->argptr = NULL;
+ c->nargptr = NULL;
+ c->bufstart = c->bufend = c->buf;
+
+ memset(&c->pause, '\0', sizeof c->pause);
+ memset(&c->timeout, '\0', sizeof c->timeout);
+}
+void
+chat_Setup(struct chat *c, const char *data, const char *phone)
+{
c->state = CHAT_EXPECT;
if (data == NULL) {
@@ -556,20 +568,17 @@ chat_Init(struct chat *c, struct physical *p, const char *data,
c->argptr = NULL;
c->nargptr = NULL;
- if (c->bufstart == NULL)
- c->bufstart = c->bufend = c->buf;
-
c->TimeoutSec = 30;
c->TimedOut = 0;
c->phone = phone;
c->abort.num = 0;
- memset(&c->pause, '\0', sizeof c->pause);
- memset(&c->timeout, '\0', sizeof c->timeout);
+ timer_Stop(&c->pause);
+ timer_Stop(&c->timeout);
}
void
-chat_Destroy(struct chat *c)
+chat_Finish(struct chat *c)
{
timer_Stop(&c->pause);
timer_Stop(&c->timeout);
@@ -578,6 +587,12 @@ chat_Destroy(struct chat *c)
c->abort.num = 0;
}
+void
+chat_Destroy(struct chat *c)
+{
+ chat_Finish(c);
+}
+
/*
* \c don't add a cr
* \d Sleep a little (delay 2 seconds
OpenPOWER on IntegriCloud