summaryrefslogtreecommitdiff
path: root/hw/xfree86/os-support/linux/lnx_init.c
diff options
context:
space:
mode:
authorAdam Jackson <ajax@redhat.com>2010-08-25 11:06:38 -0400
committerPeter Hutterer <peter.hutterer@who-t.net>2010-11-19 11:11:04 +1000
commita6b9e8f1e5d5d0b3b0f121a6f677eeca7aab1950 (patch)
tree93f53da355fef6f9bf51d1db975413b0c78b4046 /hw/xfree86/os-support/linux/lnx_init.c
parentecdbe817fd7eb53fd1e7485c0492355f7f002d2a (diff)
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>
Diffstat (limited to 'hw/xfree86/os-support/linux/lnx_init.c')
-rw-r--r--hw/xfree86/os-support/linux/lnx_init.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/hw/xfree86/os-support/linux/lnx_init.c b/hw/xfree86/os-support/linux/lnx_init.c
index bf61ceb65..7ee9046b2 100644
--- a/hw/xfree86/os-support/linux/lnx_init.c
+++ b/hw/xfree86/os-support/linux/lnx_init.c
@@ -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