[PATCH] linux: Fix CPU usage bug in console fd flushing

Adam Jackson ajax at redhat.com
Wed Aug 25 08:09:19 PDT 2010


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 at redhat.com>
---
 hw/xfree86/os-support/linux/lnx_init.c |    6 +++++-
 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 c8cec2e..21f2220 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
-- 
1.7.2.1



More information about the xorg-devel mailing list