X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on cantiga.alporthouse.com X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham version=3.3.1 X-Default-Received-SPF: pass (skip=forwardok (res=PASS)) x-ip-name=66.98.244.53; Received: from mail.surfanytime.net [109.228.6.236] by cantiga.alporthouse.com with POP3 (fetchmail-6.3.17) for (single-drop); Wed, 25 Aug 2010 16:11:09 +0100 (BST) Received: from relay.fireflyinternet.com (unverified [66.98.244.53]) by fireflyinternet.com (Firefly Internet SMTP) with ESMTP id 5153425-1500050 for ; Wed, 25 Aug 2010 16:12:00 +0100 Return-Path: Received-SPF: none (No spf1 record for (lists.x.org) ) client-ip=95.130.76.103; envelope-from=; Received: from coumta05.netbenefit.co.uk (unverified [95.130.76.103]) by relay.fireflyinternet.com (FireflyRelay1) with ESMTP id 78928622 for ; Wed, 25 Aug 2010 16:09:57 +0100 Return-Path: Received: from gabe.freedesktop.org ([131.252.210.177]:48692) by coumta05.netbenefit.co.uk with esmtp (NBT 4.61 23) id 1OoHc7-0002je-E1 for chris@chris-wilson.co.uk; Wed, 25 Aug 2010 16:10:11 +0100 Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2D1369E929 for ; Wed, 25 Aug 2010 08:10:04 -0700 (PDT) X-Original-To: xorg-devel@lists.x.org Delivered-To: xorg-devel@lists.x.org Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by gabe.freedesktop.org (Postfix) with ESMTP id 5F7D09E985 for ; Wed, 25 Aug 2010 08:09:21 -0700 (PDT) Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o7PF9Kem011689 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 25 Aug 2010 11:09:20 -0400 Received: from ihatethathostname.lab.bos.redhat.com (ihatethathostname.lab.bos.redhat.com [10.16.43.238]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o7PF9JdH022998 for ; Wed, 25 Aug 2010 11:09:20 -0400 From: Adam Jackson To: xorg-devel@lists.x.org Subject: [PATCH] linux: Fix CPU usage bug in console fd flushing Date: Wed, 25 Aug 2010 11:09:19 -0400 Message-Id: <1282748959-32003-1-git-send-email-ajax@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.21 X-BeenThere: xorg-devel@lists.x.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: "X.Org development list" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: xorg-devel-bounces+chris=chris-wilson.co.uk@lists.x.org Errors-To: xorg-devel-bounces+chris=chris-wilson.co.uk@lists.x.org X-NB-Virus-Scan: virus-free X-Originally-To: chris@chris-wilson.co.uk X-NotAscii: charset=us-ascii X-Avast: Message is clean X-IP-stats: Incoming Last 0, First 261, in=8399, out=0, spam=0 X-External-IP: 95.130.76.103 X-Rcpt-To: X-SpamDetect: **: 2.700000 From3consonants=0.7, Aspam=2.0 X-NotAscii: charset=us-ascii X-Probe: +OK skipped, from trusted ip X-Avast: Message is clean X-IP-stats: Incoming Last 0, First 30, in=1248, out=0, spam=0 ip=95.130.76.103 Status: U X-UIDL: 199491 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 --- 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 _______________________________________________ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel