Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 15 Apr 2001 21:41:24 -0700
From:      "John W. De Boskey" <jwd@FreeBSD.org>
To:        Hackers List <freebsd-hackers@FreeBSD.org>
Subject:   sys/kern/tty.c ttnread(tp) logic question
Message-ID:  <20010415214124.A93344@FreeBSD.org>

next in thread | raw e-mail | index | archive | help

Hi,

   I've been reviewing parts of the tty driver and ran into
a very basic question which I am unable to find an answer
for.  The function ttnread():

static int
ttnread(tp)
        struct tty *tp;
{
        int nread;

        if (ISSET(tp->t_lflag, PENDIN))
                ttypend(tp);
        nread = tp->t_canq.c_cc;
        if (!ISSET(tp->t_lflag, ICANON)) {
                nread += tp->t_rawq.c_cc;
                if (nread < tp->t_cc[VMIN] && tp->t_cc[VTIME] == 0)
                        nread = 0;
        }
        return (nread);
}

   sets the variable nread to t_canq.c_cc (reasonable). However, if
ICANON mode is not set (ie: the terminal is probably in raw mode),
it then adds to the value to nread. This is where my question comes
from.

   The tty linesw[] function for l_read "ttread()" has the following
near the top:

        qp = ISSET(lflag, ICANON) ?  &tp->t_canq : &tp->t_rawq;

   and the code only seems to satisfy the read request from the
single chosen queue. So it seems that it may be possible for more
data to be reported available than can actually be read.

   If anyone can shed some light on this code I would appreciate
it.

Thanks,
John

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010415214124.A93344>