linux: Fix CPU usage bug in console fd flushing
If the vt gets a vhangup from under us, then the tty will appear ready in select(), but trying to tcflush() it will return -EIO, so we'll spin around at 100% CPU for no reason. Notice this condition and unregister the handler if it happens. Signed-off-by: Adam Jackson <ajax@redhat.com> Reviewed-by: Mikhail Gusarov <dottedmag@dottedmag.net> Reviewed-by: Julien Cristau <jcristau@debian.org> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
ecdbe817fd
commit
a6b9e8f1e5
|
@ -85,7 +85,11 @@ static void *console_handler;
|
|||
static void
|
||||
drain_console(int fd, void *closure)
|
||||
{
|
||||
tcflush(fd, TCIOFLUSH);
|
||||
errno = 0;
|
||||
if (tcflush(fd, TCIOFLUSH) == -1 && errno == EIO) {
|
||||
xf86RemoveGeneralHandler(console_handler);
|
||||
console_handler = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Reference in New Issue
Block a user