xorg-x11-server/xserver-1.9.0-tcflush-fix.patch
2010-08-25 11:11:10 -04:00

36 lines
1.1 KiB
Diff

From 20e32420a2f75b58603eb1578c151d63e6b2e8ac Mon Sep 17 00:00:00 2001
From: Adam Jackson <ajax@redhat.com>
Date: Wed, 25 Aug 2010 11:06:38 -0400
Subject: [PATCH] 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>
---
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