From patchwork Tue Feb 2 19:33:09 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 44302 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 E88D8B7D57 for ; Wed, 3 Feb 2010 06:38:38 +1100 (EST) Received: from localhost ([127.0.0.1]:45868 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NcOYj-0004uf-H9 for incoming@patchwork.ozlabs.org; Tue, 02 Feb 2010 14:37:13 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NcOUy-0003mU-Cg for qemu-devel@nongnu.org; Tue, 02 Feb 2010 14:33:20 -0500 Received: from [199.232.76.173] (port=57550 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NcOUx-0003lj-EA for qemu-devel@nongnu.org; Tue, 02 Feb 2010 14:33:19 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NcOUu-00086R-VB for qemu-devel@nongnu.org; Tue, 02 Feb 2010 14:33:19 -0500 Received: from mx1.redhat.com ([209.132.183.28]:3974) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NcOUu-000866-F2 for qemu-devel@nongnu.org; Tue, 02 Feb 2010 14:33:16 -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 o12JXEKv017385 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 2 Feb 2010 14:33:15 -0500 Received: from localhost.localdomain (vpn1-5-208.ams2.redhat.com [10.36.5.208]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o12JXCJG009573 for ; Tue, 2 Feb 2010 14:33:14 -0500 From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 2 Feb 2010 20:33:09 +0100 Message-Id: <1265139191-13568-2-git-send-email-pbonzini@redhat.com> In-Reply-To: <1265139191-13568-1-git-send-email-pbonzini@redhat.com> References: <1265139191-13568-1-git-send-email-pbonzini@redhat.com> 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 1/3] do not loop on an incomplete io_thread_fd read 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 No need to loop if less than a full buffer is read, the next read would return EAGAIN. Signed-off-by: Paolo Bonzini --- vl.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/vl.c b/vl.c index 6f1e1ab..46c1118 100644 --- a/vl.c +++ b/vl.c @@ -3210,12 +3210,12 @@ static void qemu_event_read(void *opaque) { int fd = (unsigned long)opaque; ssize_t len; + char buffer[512]; /* Drain the notify pipe */ do { - char buffer[512]; len = read(fd, buffer, sizeof(buffer)); - } while ((len == -1 && errno == EINTR) || len > 0); + } while ((len == -1 && errno == EINTR) || len == sizeof(buffer)); } static int qemu_event_init(void)