From patchwork Wed Mar 10 10:03:22 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 47220 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 8FF83B7C09 for ; Wed, 10 Mar 2010 21:23:24 +1100 (EST) Received: from localhost ([127.0.0.1]:42360 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NpJ1W-0000kY-Ec for incoming@patchwork.ozlabs.org; Wed, 10 Mar 2010 05:20:18 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NpIlV-0003sS-OY for qemu-devel@nongnu.org; Wed, 10 Mar 2010 05:03:45 -0500 Received: from [199.232.76.173] (port=49332 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NpIlU-0003s8-T7 for qemu-devel@nongnu.org; Wed, 10 Mar 2010 05:03:45 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NpIlS-0001sw-2A for qemu-devel@nongnu.org; Wed, 10 Mar 2010 05:03:44 -0500 Received: from mx1.redhat.com ([209.132.183.28]:37680) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NpIlR-0001so-Jd for qemu-devel@nongnu.org; Wed, 10 Mar 2010 05:03:41 -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 o2AA3ewP017771 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 10 Mar 2010 05:03:40 -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 o2AA3SbJ017099; Wed, 10 Mar 2010 05:03:39 -0500 From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 10 Mar 2010 11:03:22 +0100 Message-Id: <0ab9450abc9b9af8afa1258518a344780248d999.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 08/14] qemu-char:tcp 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 | 18 +++++------------- 1 files changed, 5 insertions(+), 13 deletions(-) diff --git a/qemu-char.c b/qemu-char.c index 93b3ea4..063da94 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -1899,16 +1899,6 @@ static int tcp_chr_write(CharDriverState *chr, const uint8_t *buf, int len) } } -static int tcp_chr_read_poll(void *opaque) -{ - CharDriverState *chr = opaque; - TCPCharDriver *s = chr->opaque; - if (!s->connected) - return 0; - s->max_size = qemu_chr_can_read(chr); - return s->max_size; -} - #define IAC 255 #define IAC_BREAK 243 static void tcp_chr_process_IAC_bytes(CharDriverState *chr, @@ -2030,7 +2020,10 @@ static void tcp_chr_read(void *opaque) uint8_t buf[READ_BUF_LEN]; int len, size; - if (!s->connected || s->max_size <= 0) + if (!s->connected) + return; + s->max_size = qemu_chr_can_read(chr); + if (s->max_size <= 0) return; len = sizeof(buf); if (len > s->max_size) @@ -2064,8 +2057,7 @@ static void tcp_chr_connect(void *opaque) TCPCharDriver *s = chr->opaque; s->connected = 1; - qemu_set_fd_handler2(s->fd, tcp_chr_read_poll, - tcp_chr_read, NULL, chr); + qemu_set_fd_handler(s->fd, tcp_chr_read, NULL, chr); qemu_chr_generic_open(chr); }