From patchwork Wed Mar 10 10:03:24 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 47224 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 CD360B7CCD for ; Wed, 10 Mar 2010 21:28:17 +1100 (EST) Received: from localhost ([127.0.0.1]:40139 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NpJ8w-00052B-5s for incoming@patchwork.ozlabs.org; Wed, 10 Mar 2010 05:27:58 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NpIlY-0003tg-PJ for qemu-devel@nongnu.org; Wed, 10 Mar 2010 05:03:49 -0500 Received: from [199.232.76.173] (port=49336 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NpIlX-0003t2-41 for qemu-devel@nongnu.org; Wed, 10 Mar 2010 05:03:47 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NpIlV-0001tQ-3k for qemu-devel@nongnu.org; Wed, 10 Mar 2010 05:03:46 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52519) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NpIlU-0001tE-Eb for qemu-devel@nongnu.org; Wed, 10 Mar 2010 05:03:44 -0500 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 o2AA3h4k006479 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 10 Mar 2010 05:03:43 -0500 Received: from localhost.localdomain (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o2AA3SbL017099; Wed, 10 Mar 2010 05:03:42 -0500 From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 10 Mar 2010 11:03:24 +0100 Message-Id: <9302ecc91cd65e79b9a4ce1428ec5a52136088d8.1268214633.git.quintela@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.67 on 10.5.11.21 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Subject: [Qemu-devel] [PATCH 10/14] qemu-char:pty 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 | 16 +++++----------- 1 files changed, 5 insertions(+), 11 deletions(-) diff --git a/qemu-char.c b/qemu-char.c index 875f254..bc294af 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -833,15 +833,6 @@ static int pty_chr_write(CharDriverState *chr, const uint8_t *buf, int len) return send_all(s->fd, buf, len); } -static int pty_chr_read_poll(void *opaque) -{ - CharDriverState *chr = opaque; - PtyCharDriver *s = chr->opaque; - - s->read_bytes = qemu_chr_can_read(chr); - return s->read_bytes; -} - static void pty_chr_read(void *opaque) { CharDriverState *chr = opaque; @@ -849,6 +840,10 @@ static void pty_chr_read(void *opaque) int size, len; uint8_t buf[READ_BUF_LEN]; + s->read_bytes = qemu_chr_can_read(chr); + + if (s->read_bytes <= 0) + return; len = sizeof(buf); if (len > s->read_bytes) len = s->read_bytes; @@ -870,8 +865,7 @@ static void pty_chr_update_read_handler(CharDriverState *chr) { PtyCharDriver *s = chr->opaque; - qemu_set_fd_handler2(s->fd, pty_chr_read_poll, - pty_chr_read, NULL, chr); + qemu_set_fd_handler(s->fd, pty_chr_read, NULL, chr); s->polling = 1; /* * Short timeout here: just need wait long enougth that qemu makes