From patchwork Mon Sep 17 15:24:45 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bharata B Rao X-Patchwork-Id: 184451 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id F23B32C007F for ; Tue, 18 Sep 2012 01:23:18 +1000 (EST) Received: from localhost ([::1]:47335 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TDdAL-0006Gu-2W for incoming@patchwork.ozlabs.org; Mon, 17 Sep 2012 11:23:17 -0400 Received: from eggs.gnu.org ([208.118.235.92]:59246) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TDdAD-0006G8-DO for qemu-devel@nongnu.org; Mon, 17 Sep 2012 11:23:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TDdA3-0001jU-Rm for qemu-devel@nongnu.org; Mon, 17 Sep 2012 11:23:09 -0400 Received: from e28smtp08.in.ibm.com ([122.248.162.8]:42675) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TDdA3-0001ir-7q for qemu-devel@nongnu.org; Mon, 17 Sep 2012 11:22:59 -0400 Received: from /spool/local by e28smtp08.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 17 Sep 2012 20:52:54 +0530 Received: from d28relay05.in.ibm.com (9.184.220.62) by e28smtp08.in.ibm.com (192.168.1.138) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 17 Sep 2012 20:52:52 +0530 Received: from d28av02.in.ibm.com (d28av02.in.ibm.com [9.184.220.64]) by d28relay05.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q8HFMqZA31391764 for ; Mon, 17 Sep 2012 20:52:52 +0530 Received: from d28av02.in.ibm.com (loopback [127.0.0.1]) by d28av02.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q8HFMphv009728 for ; Tue, 18 Sep 2012 01:22:51 +1000 Received: from in.ibm.com ([9.79.199.95]) by d28av02.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q8HFMmCo009550 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Tue, 18 Sep 2012 01:22:50 +1000 Date: Mon, 17 Sep 2012 20:54:45 +0530 From: Bharata B Rao To: qemu-devel@nongnu.org Message-ID: <20120917152445.GE6879@in.ibm.com> References: <20120917152149.GB6879@in.ibm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20120917152149.GB6879@in.ibm.com> User-Agent: Mutt/1.5.21 (2010-09-15) x-cbid: 12091715-2000-0000-0000-000009253D6B X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 122.248.162.8 Cc: Kevin Wolf , Anthony Liguori , Anand Avati , Vijay Bellur , Stefan Hajnoczi , Amar Tumballi , Markus Armbruster , Blue Swirl , Avi Kivity , Paolo Bonzini Subject: [Qemu-devel] [PATCH v7 3/5] aio: Fix qemu_aio_wait() to maintain correct walking_handlers count X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: bharata@linux.vnet.ibm.com List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org aio: Fix qemu_aio_wait() to maintain correct walking_handlers count From: Paolo Bonzini Fix qemu_aio_wait() to ensure that registered aio handlers don't get deleted when they are still active. This is ensured by maintaning the right count of walking_handlers. Signed-off-by: Paolo Bonzini Signed-off-by: Bharata B Rao --- aio.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/aio.c b/aio.c index 0a9eb10..99b8b72 100644 --- a/aio.c +++ b/aio.c @@ -119,7 +119,7 @@ bool qemu_aio_wait(void) return true; } - walking_handlers = 1; + walking_handlers++; FD_ZERO(&rdfds); FD_ZERO(&wrfds); @@ -147,7 +147,7 @@ bool qemu_aio_wait(void) } } - walking_handlers = 0; + walking_handlers--; /* No AIO operations? Get us out of here */ if (!busy) { @@ -159,7 +159,7 @@ bool qemu_aio_wait(void) /* if we have any readable fds, dispatch event */ if (ret > 0) { - walking_handlers = 1; + walking_handlers++; /* we have to walk very carefully in case * qemu_aio_set_fd_handler is called while we're walking */ @@ -187,7 +187,7 @@ bool qemu_aio_wait(void) } } - walking_handlers = 0; + walking_handlers--; } return true;