From patchwork Thu Mar 11 16:55:43 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 47355 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id B3958B7CE4 for ; Fri, 12 Mar 2010 04:22:57 +1100 (EST) Received: from localhost ([127.0.0.1]:35836 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Npm1G-0003vZ-QJ for incoming@patchwork.ozlabs.org; Thu, 11 Mar 2010 12:17:58 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Nplg9-0004v4-Db for qemu-devel@nongnu.org; Thu, 11 Mar 2010 11:56:09 -0500 Received: from [199.232.76.173] (port=35556 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nplg8-0004uB-BY for qemu-devel@nongnu.org; Thu, 11 Mar 2010 11:56:08 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1Nplg6-0003qP-ED for qemu-devel@nongnu.org; Thu, 11 Mar 2010 11:56:08 -0500 Received: from mx1.redhat.com ([209.132.183.28]:30818) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Nplg5-0003qG-Nb for qemu-devel@nongnu.org; Thu, 11 Mar 2010 11:56:06 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o2BGu4WV009912 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 11 Mar 2010 11:56:05 -0500 Received: from localhost.localdomain (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o2BGtoNq002794; Thu, 11 Mar 2010 11:56:04 -0500 From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 11 Mar 2010 17:55:43 +0100 Message-Id: <1d4f43491268563e9867aa383789cc8fc684b2ed.1268326362.git.quintela@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Subject: [Qemu-devel] [PATCH 09/16] qemu-char:stdio insert poll call into read one X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This way we can remove the poll test Signed-off-by: Juan Quintela --- qemu-char.c | 22 +++++++--------------- 1 files changed, 7 insertions(+), 15 deletions(-) diff --git a/qemu-char.c b/qemu-char.c index 6ea4e8c..93b3ea4 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -664,8 +664,10 @@ static CharDriverState *qemu_chr_open_pipe(QemuOpts *opts) static uint8_t term_fifo[TERM_FIFO_MAX_SIZE]; static int term_fifo_size; -static int stdio_read_poll(void *opaque) +static void stdio_read(void *opaque) { + int size; + uint8_t buf[1]; CharDriverState *chr = opaque; /* try to flush the queue if needed */ @@ -673,19 +675,9 @@ static int stdio_read_poll(void *opaque) qemu_chr_read(chr, term_fifo, 1); term_fifo_size = 0; } - /* see if we can absorb more chars */ - if (term_fifo_size == 0) - return 1; - else - return 0; -} - -static void stdio_read(void *opaque) -{ - int size; - uint8_t buf[1]; - CharDriverState *chr = opaque; - + if (term_fifo_size != 0) { + return; + } size = read(0, buf, 1); if (size == 0) { /* stdin has been closed. Remove it from the active list. */ @@ -757,7 +749,7 @@ static CharDriverState *qemu_chr_open_stdio(QemuOpts *opts) return NULL; chr = qemu_chr_open_fd(0, 1); chr->chr_close = qemu_chr_close_stdio; - qemu_set_fd_handler2(0, stdio_read_poll, stdio_read, NULL, chr); + qemu_set_fd_handler(0, stdio_read, NULL, chr); stdio_nb_clients++; term_init(opts);