From ba9233fa15b32ca12a7ce20239c3149b7d185bc0 Mon Sep 17 00:00:00 2001 From: brian Date: Thu, 10 Dec 1998 18:36:30 +0000 Subject: [PATCH] When using ``set device !someprogram'', when ``someprogram'' exits, it causes a select() exception. Handle these select() exceptions on link descriptors in pretty much the same way as loss of carrier rather than dropping out in confusion. --- usr.sbin/ppp/bundle.c | 16 +++++++++++++++- usr.sbin/ppp/bundle.h | 3 ++- usr.sbin/ppp/main.c | 10 +++++++--- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/usr.sbin/ppp/bundle.c b/usr.sbin/ppp/bundle.c index b8d49fd9060e..c123f7aa4e07 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.39 1998/10/27 22:53:22 brian Exp $ + * $Id: bundle.c,v 1.40 1998/10/29 23:47:10 brian Exp $ */ #include @@ -1729,3 +1729,17 @@ bundle_HighestState(struct bundle *bundle) return result; } + +int +bundle_Exception(struct bundle *bundle, int fd) +{ + struct datalink *dl; + + for (dl = bundle->links; dl; dl = dl->next) + if (dl->physical->fd == fd) { + datalink_Down(dl, CLOSE_NORMAL); + return 1; + } + + return 0; +} diff --git a/usr.sbin/ppp/bundle.h b/usr.sbin/ppp/bundle.h index e3df0b572f13..0eb20e44a748 100644 --- a/usr.sbin/ppp/bundle.h +++ b/usr.sbin/ppp/bundle.h @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: bundle.h,v 1.18 1998/10/27 22:53:22 brian Exp $ + * $Id: bundle.h,v 1.19 1998/10/29 02:12:54 brian Exp $ */ #define PHASE_DEAD 0 /* Link is dead */ @@ -184,3 +184,4 @@ extern int bundle_RenameDatalink(struct bundle *, struct datalink *, extern void bundle_setsid(struct bundle *, int); extern void bundle_LockTun(struct bundle *); extern int bundle_HighestState(struct bundle *); +extern int bundle_Exception(struct bundle *, int); diff --git a/usr.sbin/ppp/main.c b/usr.sbin/ppp/main.c index 218d193ff2e1..b9cf61d4f0fd 100644 --- a/usr.sbin/ppp/main.c +++ b/usr.sbin/ppp/main.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: main.c,v 1.144 1998/10/22 02:32:49 brian Exp $ + * $Id: main.c,v 1.145 1998/10/31 17:38:46 brian Exp $ * * TODO: */ @@ -515,8 +515,12 @@ DoLoop(struct bundle *bundle) for (i = 0; i <= nfds; i++) if (FD_ISSET(i, &efds)) { - log_Printf(LogERROR, "Exception detected on descriptor %d\n", i); - break; + log_Printf(LogPHASE, "Exception detected on descriptor %d\n", i); + /* We deal gracefully with link descriptor exceptions */ + if (!bundle_Exception(bundle, i)) { + log_Printf(LogERROR, "Exception cannot be handled !\n"); + break; + } } if (i <= nfds)