From da8b70349bbc22516fc4a6c703c963898e17b1f8 Mon Sep 17 00:00:00 2001 From: Brian Somers Date: Tue, 9 Nov 1999 23:21:47 +0000 Subject: [PATCH] Don't recurse into datalink_UpdateSet() after doing a HangupDone(). The HangupDone() may fuel bundle_CleanDatalinks(), and if so, the bogus UpdateSet() ends up select()ing on a closed descriptor..... Change the main `do/while' loop to a `for' loop so that any `continue's do the bundle_CleanDatalinks() & bundle_IsDead() bit. --- usr.sbin/ppp/datalink.c | 6 ++++-- usr.sbin/ppp/main.c | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/usr.sbin/ppp/datalink.c b/usr.sbin/ppp/datalink.c index 40f22f1fc8ba..31c74c07c159 100644 --- a/usr.sbin/ppp/datalink.c +++ b/usr.sbin/ppp/datalink.c @@ -332,9 +332,11 @@ datalink_UpdateSet(struct descriptor *d, fd_set *r, fd_set *w, fd_set *e, if (dl->script.run) { datalink_NewState(dl, DATALINK_HANGUP); chat_Init(&dl->chat, dl->physical, dl->cfg.script.hangup, NULL); - } else + return datalink_UpdateSet(d, r, w, e, n); + } else { datalink_HangupDone(dl); - return datalink_UpdateSet(d, r, w, e, n); + return 0; /* Maybe bundle_CleanDatalinks() has something to do */ + } } case DATALINK_HANGUP: diff --git a/usr.sbin/ppp/main.c b/usr.sbin/ppp/main.c index 2cce11ee36e6..cbe0f5586cd6 100644 --- a/usr.sbin/ppp/main.c +++ b/usr.sbin/ppp/main.c @@ -506,7 +506,7 @@ DoLoop(struct bundle *bundle) probe_Init(&probe); - do { + for (; !bundle_IsDead(bundle); bundle_CleanDatalinks(bundle)) { nfds = 0; FD_ZERO(&rfds); FD_ZERO(&wfds); @@ -619,7 +619,7 @@ DoLoop(struct bundle *bundle) t.tv_usec = 100000; select(0, NULL, NULL, NULL, &t); } - } while (bundle_CleanDatalinks(bundle), !bundle_IsDead(bundle)); + } log_Printf(LogDEBUG, "DoLoop done.\n"); }