[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.LFD.2.01.0907280843050.3186@localhost.localdomain>
Date: Tue, 28 Jul 2009 08:48:02 -0700 (PDT)
From: Linus Torvalds <torvalds@...ux-foundation.org>
To: OGAWA Hirofumi <hirofumi@...l.parknet.co.jp>
cc: Alan Cox <alan@...rguk.ukuu.org.uk>,
"Aneesh Kumar K.V" <aneesh.kumar@...ux.vnet.ibm.com>,
"Rafael J. Wysocki" <rjw@...k.pl>, Ray Lee <ray-lk@...rabbit.org>,
LKML <linux-kernel@...r.kernel.org>,
Andrew Morton <akpm@...ux-foundation.org>
Subject: Re: [PATCH] kdesu broken
On Tue, 28 Jul 2009, OGAWA Hirofumi wrote:
>
> Just a quick hack though. Is this wrong/unpreferable way?
That seems to be right regardless of any other issues.
> n_tty_read() checks the pending buffer and consume it before
> input_available_p().
Why not move this _inside_ "input_available_p()"? There are only two
call-sites, and strictly speaking they both want it.
Look at n_tty_poll(), for example:
if (input_available_p(tty, TIME_CHAR(tty) ? 0 : MIN_CHAR(tty)))
mask |= POLLIN | POLLRDNORM;
if (tty->packet && tty->link->ctrl_status)
mask |= POLLPRI | POLLIN | POLLRDNORM;
if (test_bit(TTY_OTHER_CLOSED, &tty->flags))
mask |= POLLHUP;
if (tty_hung_up_p(file))
mask |= POLLHUP;
and notice what happens to somebody who uses select/poll when there might
be pending data that hasn't been handled yet, and the tty has been marked
TTY_OTHER_CLOSED or hung up. It would return only POLLHUP, and as a
result, that side would never even try to read the pending data because
poll implies that there is no data and it's EOF. Which is just wrong.
So _any_ time you check "is there input available?" you should always
check if there are other buffers. No?
Linus
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists