lkml.org 
[lkml]   [2009]   [Jul]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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


\
 
 \ /
  Last update: 2009-10-18 23:28    [W:0.204 / U:0.500 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site