X-Git-Url: https://git.ozlabs.org/?p=ppp.git;a=blobdiff_plain;f=freebsd-2.0%2Fppp_tty.c;h=5ad17d22572a8d75f0bd72b362c028db643ca410;hp=1a073372a1711afa0ac32e4ccc2821d85d38d796;hb=cb3847ef25bc935ef66c39c919c0b375358b09b1;hpb=f21bd17076cc5ff4d7be91a33ea9a855ac5a9cd9 diff --git a/freebsd-2.0/ppp_tty.c b/freebsd-2.0/ppp_tty.c index 1a07337..5ad17d2 100644 --- a/freebsd-2.0/ppp_tty.c +++ b/freebsd-2.0/ppp_tty.c @@ -70,7 +70,7 @@ * Paul Mackerras (paulus@cs.anu.edu.au). */ -/* $Id: ppp_tty.c,v 1.1 1994/12/15 22:28:09 paulus Exp $ */ +/* $Id: ppp_tty.c,v 1.3 1995/08/16 01:36:40 paulus Exp $ */ /* from if_sl.c,v 1.11 84/10/04 12:54:47 rick Exp */ #include "ppp.h" @@ -157,7 +157,7 @@ static void ppplogchar __P((struct ppp_softc *, int)); static struct linesw pppdisc = { pppopen, pppclose, pppread, pppwrite, ppptioctl, - pppinput, pppstart, nullmodem + pppinput, pppstart, ttymodem }; void @@ -287,26 +287,34 @@ pppread(tp, uio, flag) register int s; int error = 0; - if ((tp->t_state & TS_CARR_ON) == 0 && (tp->t_cflag & CLOCAL) == 0) - return 0; /* end of file */ - if (sc == NULL || tp != (struct tty *) sc->sc_devp) + if (sc == NULL) return 0; + /* + * Loop waiting for input, checking that nothing disasterous + * happens in the meantime. + */ s = splimp(); - while (sc->sc_inq.ifq_head == NULL && tp->t_line == PPPDISC) { + for (;;) { + if (tp != (struct tty *) sc->sc_devp || tp->t_line != PPPDISC) { + splx(s); + return 0; + } + if (sc->sc_inq.ifq_head != NULL) + break; + if ((tp->t_state & TS_CONNECTED) == 0 && (tp->t_state & TS_ISOPEN)) { + splx(s); + return 0; /* end of file */ + } if (tp->t_state & TS_ASYNC || flag & IO_NDELAY) { splx(s); return (EWOULDBLOCK); } - error = ttysleep(tp, (caddr_t)&tp->t_rawq, TTIPRI|PCATCH, ttyin, 0); + error = ttysleep(tp, TSA_HUP_OR_INPUT(tp), TTIPRI | PCATCH, "pppin", 0); if (error) { splx(s); return error; } } - if (tp->t_line != PPPDISC) { - splx(s); - return (-1); - } /* Pull place-holder byte out of canonical queue */ getc(&tp->t_canq); @@ -336,7 +344,7 @@ pppwrite(tp, uio, flag) struct sockaddr dst; int len, error; - if ((tp->t_state & TS_CARR_ON) == 0 && (tp->t_cflag & CLOCAL) == 0) + if ((tp->t_state & TS_CONNECTED) == 0) return 0; /* wrote 0 bytes */ if (tp->t_line != PPPDISC) return (EINVAL); @@ -534,7 +542,7 @@ pppstart(tp) int n, s, ndone, done, idle; struct mbuf *m2; - if ((tp->t_state & TS_CARR_ON) == 0 && (tp->t_cflag & CLOCAL) == 0 + if ((tp->t_state & TS_CONNECTED) == 0 || sc == NULL || tp != (struct tty *) sc->sc_devp) { if (tp->t_oproc != NULL) (*tp->t_oproc)(tp); @@ -686,7 +694,7 @@ pppstart(tp) } /* - * If there is stuff in the output queue, send it now. + * Send anything that may be in the output queue. * We are being called in lieu of ttstart and must do what it would. */ if (tp->t_oproc != NULL)