Obtained from: partly from ancient patches of mine via 1.1.5

Introduce TS_CONNECTED and TS_ZOMBIE states.  TS_CONNECTED is set
while a connection is established.  It is set while (TS_CARR_ON or
CLOCAL is set) and TS_ZOMBIE is clear.  TS_ZOMBIE is set for on to
off transitions of TS_CARR_ON that occur when CLOCAL is clear and
is cleared for off to on transitions of CLOCAL.  I/o can only occur
while TS_CONNECTED is set.  TS_ZOMBIE prevents further i/o.

Split the input-event sleep address TSA_CARR_ON(tp) into TSA_CARR_ON(tp)
and TSA_HUP_OR_INPUT(tp).  The former address is now used only for
off to on carrier transitions and equivalent CLOCAL transitions.
The latter is used for all input events, all carrier transitions
and certain CLOCAL transitions.  There are some harmless extra
wakeups for rare connection- related events.  Previously there were
too many extra wakeups for non-rare input events.

Drivers now call l_modem() instead of setting TS_CARR_ON directly
to handle even the initial off to on transition of carrier.  They
should always have done this.  l_modem() now handles TS_CONNECTED
and TS_ZOMBIE as well as TS_CARR_ON.

gnu/isdn/iitty.c:
Set TS_CONNECTED for first open ourself to go with bogusly setting
CLOCAL.

i386/isa/syscons.c, i386/isa/pcvt/pcvt_drv.c:
We fake carrier, so don't also fake CLOCAL.

kern/tty.c:
Testing TS_CONNECTED instead of TS_CARR_ON fixes TIOCCONS forgetting to
test CLOCAL.  TS_ISOPEN was tested instead, but that broke when we disabled
the clearing of TS_ISOPEN for certain transitions of CLOCAL.

Testing TS_CONNECTED fixes ttyselect() returning false success for output
to devices in state !TS_CARR_ON && !CLOCAL.

Optimize the other selwakeup() call (this is not related to the other
changes).

kern/tty_pty.c:
ptcopen() can be declared in traditional C now that dev_t isn't short.
This commit is contained in:
bde 1995-07-31 21:02:00 +00:00
parent 97c9306034
commit 4975b5a1d6
11 changed files with 124 additions and 104 deletions

View File

@ -25,7 +25,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: syscons.c,v 1.120 1995/07/11 18:34:29 bde Exp $
* $Id: syscons.c,v 1.121 1995/07/22 01:30:05 bde Exp $
*/
#include "sc.h"
@ -352,12 +352,11 @@ scopen(dev_t dev, int flag, int mode, struct proc *p)
tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED;
scparam(tp, &tp->t_termios);
ttsetwater(tp);
(*linesw[tp->t_line].l_modem)(tp, 1);
}
else
if (tp->t_state & TS_XCLUDE && p->p_ucred->cr_uid != 0)
return(EBUSY);
tp->t_state |= TS_CARR_ON;
tp->t_cflag |= CLOCAL;
if (!console[minor(dev)])
console[minor(dev)] = alloc_scp();
return((*linesw[tp->t_line].l_open)(dev, tp));

View File

@ -1,6 +1,6 @@
static char _ittyid[] = "@(#)$Id: iitty.c,v 1.8 1995/07/22 01:29:28 bde Exp $";
static char _ittyid[] = "@(#)$Id: iitty.c,v 1.9 1995/07/22 16:44:26 bde Exp $";
/*******************************************************************************
* II - Version 0.1 $Revision: 1.8 $ $State: Exp $
* II - Version 0.1 $Revision: 1.9 $ $State: Exp $
*
* Copyright 1994 Dietmar Friede
*******************************************************************************
@ -10,6 +10,12 @@ static char _ittyid[] = "@(#)$Id: iitty.c,v 1.8 1995/07/22 01:29:28 bde Exp
*
*******************************************************************************
* $Log: iitty.c,v $
* Revision 1.9 1995/07/22 16:44:26 bde
* Obtained from: partly from ancient patches of mine via 1.1.5
*
* Give names to the magic tty i/o sleep addresses and use them. This makes
* it easier to remember what the addresses are for and to keep them unique.
*
* Revision 1.8 1995/07/22 01:29:28 bde
* Move the inline code for waking up writers to a new function
* ttwwakeup(). The conditions for doing the wakeup will soon become
@ -159,7 +165,14 @@ ityopen(dev_t dev, int flag, int mode, struct proc * p)
return (EBUSY);
(void) spltty();
if(OUTBOUND(dev)) tp->t_cflag |= CLOCAL;
if (OUTBOUND(dev)) {
/*
* XXX should call l_modem() here and not meddle with CLOCAL,
* but itystart() wants TS_CARR_ON to give the true carrier.
*/
tp->t_cflag |= CLOCAL;
tp->t_state |= TS_CONNECTED;
}
while ((flag & O_NONBLOCK) == 0 && (tp->t_cflag & CLOCAL) == 0 &&
(tp->t_state & TS_CARR_ON) == 0)
@ -286,7 +299,6 @@ ity_connect(int no)
return;
if(OUTBOUND(tp->t_dev)) tp->t_cflag &= ~CLOCAL;
(*linesw[tp->t_line].l_modem) (tp, 1);
tp->t_state |= TS_CARR_ON;
tp->t_state &=~ (TS_BUSY|TS_FLUSH);
if (tp->t_line)
(*linesw[tp->t_line].l_start)(tp);

View File

@ -194,7 +194,7 @@ int cxopen (dev_t dev, int flag, int mode, struct proc *p)
cx_chan_rts (c, 1);
}
if (cx_chan_cd (c))
tp->t_state |= TS_CARR_ON;
(*linesw[tp->t_line].l_modem)(tp, 1);
if (! (flag & O_NONBLOCK)) {
/* Lock the channel against cxconfig while we are
* waiting for carrier. */

View File

@ -433,16 +433,12 @@ pcopen(Dev_t dev, int flag, int mode, struct proc *p)
tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED;
pcparam(tp, &tp->t_termios);
ttsetwater(tp);
(*linesw[tp->t_line].l_modem)(tp, 1); /* fake connection */
winsz = 1; /* set winsize later */
}
else if (tp->t_state & TS_XCLUDE && p->p_ucred->cr_uid != 0)
return (EBUSY);
tp->t_state |= TS_CARR_ON;
tp->t_cflag |= CLOCAL; /* cannot be a modem (:-) */
if ((tp->t_state & TS_ISOPEN) == 0) /* is this a "cold" open ? */
winsz = 1; /* yes, set winsize later */
#if PCVT_NETBSD || (PCVT_FREEBSD >= 200)
retval = ((*linesw[tp->t_line].l_open)(dev, tp));
#else

View File

@ -25,7 +25,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: syscons.c,v 1.120 1995/07/11 18:34:29 bde Exp $
* $Id: syscons.c,v 1.121 1995/07/22 01:30:05 bde Exp $
*/
#include "sc.h"
@ -352,12 +352,11 @@ scopen(dev_t dev, int flag, int mode, struct proc *p)
tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED;
scparam(tp, &tp->t_termios);
ttsetwater(tp);
(*linesw[tp->t_line].l_modem)(tp, 1);
}
else
if (tp->t_state & TS_XCLUDE && p->p_ucred->cr_uid != 0)
return(EBUSY);
tp->t_state |= TS_CARR_ON;
tp->t_cflag |= CLOCAL;
if (!console[minor(dev)])
console[minor(dev)] = alloc_scp();
return((*linesw[tp->t_line].l_open)(dev, tp));

View File

@ -25,7 +25,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: syscons.c,v 1.120 1995/07/11 18:34:29 bde Exp $
* $Id: syscons.c,v 1.121 1995/07/22 01:30:05 bde Exp $
*/
#include "sc.h"
@ -352,12 +352,11 @@ scopen(dev_t dev, int flag, int mode, struct proc *p)
tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED;
scparam(tp, &tp->t_termios);
ttsetwater(tp);
(*linesw[tp->t_line].l_modem)(tp, 1);
}
else
if (tp->t_state & TS_XCLUDE && p->p_ucred->cr_uid != 0)
return(EBUSY);
tp->t_state |= TS_CARR_ON;
tp->t_cflag |= CLOCAL;
if (!console[minor(dev)])
console[minor(dev)] = alloc_scp();
return((*linesw[tp->t_line].l_open)(dev, tp));

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)tty.c 8.8 (Berkeley) 1/21/94
* $Id: tty.c,v 1.61 1995/07/31 18:29:28 bde Exp $
* $Id: tty.c,v 1.62 1995/07/31 19:17:11 bde Exp $
*/
/*-
@ -772,8 +772,7 @@ ttioctl(tp, cmd, data, flag)
case TIOCCONS: /* become virtual console */
if (*(int *)data) {
if (constty && constty != tp &&
ISSET(constty->t_state, TS_CARR_ON | TS_ISOPEN) ==
(TS_CARR_ON | TS_ISOPEN))
ISSET(constty->t_state, TS_CONNECTED))
return (EBUSY);
#ifndef UCONSOLE
if (error = suser(p->p_ucred, &p->p_acflag))
@ -842,20 +841,30 @@ ttioctl(tp, cmd, data, flag)
if (tp->t_param && (error = (*tp->t_param)(tp, t))) {
splx(s);
return (error);
} else {
if (!ISSET(tp->t_state, TS_CARR_ON) &&
ISSET(tp->t_cflag, CLOCAL) &&
!ISSET(t->c_cflag, CLOCAL)) {
#if 0
CLR(tp->t_state, TS_ISOPEN);
#endif
ttwakeup(tp);
}
ttwwakeup(tp);
tp->t_cflag = t->c_cflag;
tp->t_ispeed = t->c_ispeed;
tp->t_ospeed = t->c_ospeed;
}
if (ISSET(t->c_cflag, CLOCAL) &&
!ISSET(tp->t_cflag, CLOCAL)) {
/*
* XXX disconnections would be too hard to
* get rid of without this kludge. The only
* way to get rid of controlling terminals
* is to exit from the session leader.
*/
CLR(tp->t_state, TS_ZOMBIE);
wakeup(TSA_CARR_ON(tp));
ttwakeup(tp);
ttwwakeup(tp);
}
if ((ISSET(tp->t_state, TS_CARR_ON) ||
ISSET(t->c_cflag, CLOCAL)) &&
!ISSET(tp->t_state, TS_ZOMBIE))
SET(tp->t_state, TS_CONNECTED);
else
CLR(tp->t_state, TS_CONNECTED);
tp->t_cflag = t->c_cflag;
tp->t_ispeed = t->c_ispeed;
tp->t_ospeed = t->c_ospeed;
ttsetwater(tp);
}
if (ISSET(t->c_lflag, ICANON) != ISSET(tp->t_lflag, ICANON) &&
@ -1018,13 +1027,14 @@ ttyselect(tp, rw, p)
s = spltty();
switch (rw) {
case FREAD:
if (ttnread(tp) > 0 || (!ISSET(tp->t_cflag, CLOCAL) &&
!ISSET(tp->t_state, TS_CARR_ON)))
if (ttnread(tp) > 0 || ISSET(tp->t_state, TS_ZOMBIE))
goto win;
selrecord(p, &tp->t_rsel);
break;
case FWRITE:
if (tp->t_outq.c_cc <= tp->t_lowat) {
if ((tp->t_outq.c_cc <= tp->t_lowat &&
ISSET(tp->t_state, TS_CONNECTED))
|| ISSET(tp->t_state, TS_ZOMBIE)) {
win: splx(s);
return (1);
}
@ -1080,11 +1090,10 @@ ttywait(tp)
error = 0;
s = spltty();
while ((tp->t_outq.c_cc || ISSET(tp->t_state, TS_BUSY)) &&
(ISSET(tp->t_state, TS_CARR_ON) || ISSET(tp->t_cflag, CLOCAL))
&& tp->t_oproc) {
ISSET(tp->t_state, TS_CONNECTED) && tp->t_oproc) {
(*tp->t_oproc)(tp);
if ((tp->t_outq.c_cc || ISSET(tp->t_state, TS_BUSY)) &&
(ISSET(tp->t_state, TS_CARR_ON) || ISSET(tp->t_cflag, CLOCAL))) {
ISSET(tp->t_state, TS_CONNECTED)) {
SET(tp->t_state, TS_SO_OCOMPLETE);
error = ttysleep(tp, TSA_OCOMPLETE(tp),
TTOPRI | PCATCH, "ttywai",
@ -1306,6 +1315,8 @@ ttymodem(tp, flag)
CLR(tp->t_state, TS_CARR_ON);
if (ISSET(tp->t_state, TS_ISOPEN) &&
!ISSET(tp->t_cflag, CLOCAL)) {
SET(tp->t_state, TS_ZOMBIE);
CLR(tp->t_state, TS_CONNECTED);
if (tp->t_session && tp->t_session->s_leader)
psignal(tp->t_session->s_leader, SIGHUP);
ttyflush(tp, FREAD | FWRITE);
@ -1316,6 +1327,9 @@ ttymodem(tp, flag)
* Carrier now on.
*/
SET(tp->t_state, TS_CARR_ON);
if (!ISSET(tp->t_state, TS_ZOMBIE))
SET(tp->t_state, TS_CONNECTED);
wakeup(TSA_CARR_ON(tp));
ttwakeup(tp);
ttwwakeup(tp);
}
@ -1364,7 +1378,7 @@ ttread(tp, uio, flag)
register tcflag_t lflag;
register cc_t *cc = tp->t_cc;
register struct proc *p = curproc;
int s, first, error = 0, carrier;
int s, first, error = 0;
int has_stime = 0, last_cc = 0;
long slp = 0; /* XXX this should be renamed `timo'. */
@ -1397,6 +1411,11 @@ ttread(tp, uio, flag)
goto loop;
}
if (ISSET(tp->t_state, TS_ZOMBIE)) {
splx(s);
return (0); /* EOF */
}
/*
* If canonical, use the canonical queue,
* else use the raw queue.
@ -1408,10 +1427,7 @@ ttread(tp, uio, flag)
if (flag & IO_NDELAY) {
if (qp->c_cc > 0)
goto read;
carrier = ISSET(tp->t_state, TS_CARR_ON) ||
ISSET(tp->t_cflag, CLOCAL);
if ((!carrier && ISSET(tp->t_state, TS_ISOPEN)) ||
!ISSET(lflag, ICANON) && cc[VMIN] == 0) {
if (!ISSET(lflag, ICANON) && cc[VMIN] == 0) {
splx(s);
return (0);
}
@ -1501,22 +1517,13 @@ ttread(tp, uio, flag)
slp = (long) (((u_long)slp * hz) + 999999) / 1000000;
goto sleep;
}
/*
* If there is no input, sleep on rawq
* awaiting hardware receipt and notification.
* If we have data, we don't need to check for carrier.
*/
if (qp->c_cc <= 0) {
sleep:
carrier = ISSET(tp->t_state, TS_CARR_ON) ||
ISSET(tp->t_cflag, CLOCAL);
if (!carrier && ISSET(tp->t_state, TS_ISOPEN)) {
splx(s);
return (0); /* EOF */
}
error = ttysleep(tp, TSA_CARR_ON(tp), TTIPRI | PCATCH,
carrier ?
/*
* There is no input, or not enough input and we can block.
*/
error = ttysleep(tp, TSA_HUP_OR_INPUT(tp), TTIPRI | PCATCH,
ISSET(tp->t_state, TS_CONNECTED) ?
"ttyin" : "ttyhup", (int)slp);
splx(s);
if (error == EWOULDBLOCK)
@ -1690,23 +1697,24 @@ ttwrite(tp, uio, flag)
cc = 0;
loop:
s = spltty();
if (!ISSET(tp->t_state, TS_CARR_ON) &&
!ISSET(tp->t_cflag, CLOCAL)) {
if (ISSET(tp->t_state, TS_ISOPEN)) {
splx(s);
return (EIO);
} else if (flag & IO_NDELAY) {
if (ISSET(tp->t_state, TS_ZOMBIE)) {
splx(s);
if (uio->uio_resid == cnt)
error = EIO;
goto out;
}
if (!ISSET(tp->t_state, TS_CONNECTED)) {
if (flag & IO_NDELAY) {
splx(s);
error = EWOULDBLOCK;
goto out;
} else {
error = ttysleep(tp, TSA_CARR_ON(tp), TTIPRI | PCATCH,
"ttydcd", 0);
splx(s);
if (error)
goto out;
goto loop;
}
error = ttysleep(tp, TSA_CARR_ON(tp), TTIPRI | PCATCH,
"ttydcd", 0);
splx(s);
if (error)
goto out;
goto loop;
}
splx(s);
/*
@ -2040,10 +2048,11 @@ ttwakeup(tp)
register struct tty *tp;
{
selwakeup(&tp->t_rsel);
if (tp->t_rsel.si_pid != 0)
selwakeup(&tp->t_rsel);
if (ISSET(tp->t_state, TS_ASYNC))
pgsignal(tp->t_pgrp, SIGIO, 1);
wakeup(TSA_CARR_ON(tp));
wakeup(TSA_HUP_OR_INPUT(tp));
}
/*
@ -2250,8 +2259,7 @@ tputchar(c, tp)
register int s;
s = spltty();
if (ISSET(tp->t_state,
TS_CARR_ON | TS_ISOPEN) != (TS_CARR_ON | TS_ISOPEN)) {
if (!ISSET(tp->t_state, TS_CONNECTED)) {
splx(s);
return (-1);
}

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)tty_pty.c 8.2 (Berkeley) 9/23/93
* $Id: tty_pty.c,v 1.14 1995/07/22 01:30:32 bde Exp $
* $Id: tty_pty.c,v 1.15 1995/07/22 16:45:08 bde Exp $
*/
/*
@ -132,7 +132,7 @@ ptsopen(dev, flag, devtype, p)
} else if (tp->t_state&TS_XCLUDE && p->p_ucred->cr_uid != 0)
return (EBUSY);
if (tp->t_oproc) /* Ctrlr still around. */
tp->t_state |= TS_CARR_ON;
(void)(*linesw[tp->t_line].l_modem)(tp, 1);
while ((tp->t_state & TS_CARR_ON) == 0) {
if (flag&FNONBLOCK)
break;
@ -268,17 +268,11 @@ ptcwakeup(tp, flag)
}
}
/*ARGSUSED*/
#ifdef __STDC__
int
ptcopen(dev_t dev, int flag, int devtype, struct proc *p)
#else
int
ptcopen(dev, flag, devtype, p)
dev_t dev;
int flag, devtype;
struct proc *p;
#endif
{
register struct tty *tp;
struct pt_ioctl *pti;
@ -309,7 +303,19 @@ ptcclose(dev)
tp = &pt_tty[minor(dev)];
(void)(*linesw[tp->t_line].l_modem)(tp, 0);
tp->t_state &= ~TS_CARR_ON;
/*
* XXX MDMBUF makes no sense for ptys but would inhibit the above
* l_modem(). CLOCAL makes sense but isn't supported. Special
* l_modem()s that ignore carrier drop make no sense for ptys but
* may be in use because other parts of the line discipline make
* sense for ptys. Recover by doing everything that a normal
* ttymodem() would have done except for sending a SIGHUP.
*/
tp->t_state &= ~(TS_CARR_ON | TS_CONNECTED);
tp->t_state |= TS_ZOMBIE;
ttyflush(tp, FREAD | FWRITE);
tp->t_oproc = 0; /* mark closed */
tp->t_session = 0;
return (0);
@ -357,7 +363,7 @@ ptcread(dev, uio, flag)
if (tp->t_outq.c_cc && (tp->t_state&TS_TTSTOP) == 0)
break;
}
if ((tp->t_state&TS_CARR_ON) == 0)
if ((tp->t_state & TS_CONNECTED) == 0)
return (0); /* EOF */
if (flag & IO_NDELAY)
return (EWOULDBLOCK);
@ -411,7 +417,7 @@ ptcselect(dev, rw, p)
struct pt_ioctl *pti = &pt_ioctl[minor(dev)];
int s;
if ((tp->t_state&TS_CARR_ON) == 0)
if ((tp->t_state & TS_CONNECTED) == 0)
return (1);
switch (rw) {
@ -511,7 +517,7 @@ ptcwrite(dev, uio, flag)
while (cc > 0) {
if ((tp->t_rawq.c_cc + tp->t_canq.c_cc) >= TTYHOG - 2 &&
(tp->t_canq.c_cc > 0 || !(tp->t_iflag&ICANON))) {
wakeup(TSA_CARR_ON(tp));
wakeup(TSA_HUP_OR_INPUT(tp));
goto block;
}
(*linesw[tp->t_line].l_rint)(*cp++, tp);
@ -526,7 +532,7 @@ ptcwrite(dev, uio, flag)
* Come here to wait for slave to open, for space
* in outq, or space in rawq.
*/
if ((tp->t_state&TS_CARR_ON) == 0)
if ((tp->t_state & TS_CONNECTED) == 0)
return (EIO);
if (flag & IO_NDELAY) {
/* adjust for data copied in but not written */

View File

@ -69,7 +69,7 @@
* Paul Mackerras (paulus@cs.anu.edu.au).
*/
/* $Id: if_ppp.c,v 1.16 1995/07/21 20:52:55 bde Exp $ */
/* $Id: if_ppp.c,v 1.17 1995/07/29 13:39:44 bde Exp $ */
/* from if_sl.c,v 1.11 84/10/04 12:54:47 rick Exp */
#include "ppp.h"
@ -381,7 +381,7 @@ pppread(tp, uio, flag)
register int s;
int error = 0;
if ((tp->t_state & TS_CARR_ON) == 0 && (tp->t_cflag & CLOCAL) == 0)
if ((tp->t_state & TS_CONNECTED) == 0)
return 0; /* end of file */
if (sc == NULL || tp != (struct tty *) sc->sc_devp)
return 0;
@ -391,7 +391,7 @@ pppread(tp, uio, flag)
splx(s);
return (EWOULDBLOCK);
}
error = ttysleep(tp, (caddr_t)&tp->t_rawq, TTIPRI|PCATCH, "pppin", 0);
error = ttysleep(tp, TSA_HUP_OR_INPUT(tp), TTIPRI | PCATCH, "pppin", 0);
if (error)
return error;
}
@ -429,7 +429,7 @@ pppwrite(tp, uio, flag)
struct ppp_header *ph1, *ph2;
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);
@ -891,7 +891,7 @@ pppstart(tp)
int n, s, ndone, done;
struct mbuf *m2;
if ((tp->t_state & TS_CARR_ON) == 0 && (tp->t_cflag & CLOCAL) == 0) {
if ((tp->t_state & TS_CONNECTED) == 0) {
/* sorry, I can't talk now */
return 0;
}
@ -1293,7 +1293,7 @@ pppinput(c, tp)
++sc->sc_bytesrcvd;
if (!(tp->t_state & TS_CARR_ON) && !(tp->t_cflag & CLOCAL)) {
if ((tp->t_state & TS_CONNECTED) == 0) {
if (sc->sc_flags & SC_DEBUG)
printf("ppp%d: no carrier\n", sc->sc_if.if_unit);
goto flush;

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)if_sl.c 8.6 (Berkeley) 2/1/94
* $Id: if_sl.c,v 1.26 1995/07/07 01:13:49 davidg Exp $
* $Id: if_sl.c,v 1.27 1995/07/29 13:39:46 bde Exp $
*/
/*
@ -444,8 +444,7 @@ sloutput(ifp, m, dst, rtp)
m_freem(m);
return (ENETDOWN);
}
if ((sc->sc_ttyp->t_state & TS_CARR_ON) == 0 &&
(sc->sc_ttyp->t_cflag & CLOCAL) == 0) {
if ((sc->sc_ttyp->t_state & TS_CONNECTED) == 0) {
m_freem(m);
return (EHOSTUNREACH);
}
@ -731,8 +730,7 @@ slinput(c, tp)
sc = (struct sl_softc *)tp->t_sc;
if (sc == NULL)
return 0;
if (c & TTY_ERRORMASK || ((tp->t_state & TS_CARR_ON) == 0 &&
(tp->t_cflag & CLOCAL) == 0)) {
if (c & TTY_ERRORMASK || (tp->t_state & TS_CONNECTED) == 0) {
sc->sc_flags |= SC_ERROR;
return 0;
}

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)tty.h 8.6 (Berkeley) 1/21/94
* $Id: tty.h,v 1.27 1995/07/31 18:29:37 bde Exp $
* $Id: tty.h,v 1.28 1995/07/31 19:17:19 bde Exp $
*/
#ifndef _SYS_TTY_H_
@ -154,8 +154,10 @@ struct tty {
/* Extras. */
#define TS_CAN_BYPASS_L_RINT 0x010000 /* Device in "raw" mode. */
#define TS_CONNECTED 0x020000 /* Connection open. */
#define TS_SNOOP 0x040000 /* Device is being snooped on. */
#define TS_SO_OCOMPLETE 0x080000 /* Wake up when output completes. */
#define TS_ZOMBIE 0x100000 /* Connection lost. */
/* Character type information. */
#define ORDINARY 0
@ -195,7 +197,8 @@ struct speedtab {
(isctty((p), (tp)) && (p)->p_pgrp != (tp)->t_pgrp)
/* Unique sleep addresses. */
#define TSA_CARR_ON(tp) ((void *)&(tp)->t_rawq) /* XXX overloaded */
#define TSA_CARR_ON(tp) ((void *)&(tp)->t_rawq)
#define TSA_HUP_OR_INPUT(tp) ((void *)&(tp)->t_rawq.c_cf)
#define TSA_OCOMPLETE(tp) ((void *)&(tp)->t_outq.c_cl)
#define TSA_OLOWAT(tp) ((void *)&(tp)->t_outq)
#define TSA_PTC_READ(tp) ((void *)&(tp)->t_outq.c_cf)