From patchwork Mon Sep 24 09:10:56 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: 186331 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 F0CDF2C007B for ; Mon, 24 Sep 2012 19:09:39 +1000 (EST) Received: from localhost ([::1]:58432 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TG4fZ-0004Um-3H for incoming@patchwork.ozlabs.org; Mon, 24 Sep 2012 05:09:37 -0400 Received: from eggs.gnu.org ([208.118.235.92]:37907) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TG4fL-0004Tk-BH for qemu-devel@nongnu.org; Mon, 24 Sep 2012 05:09:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TG4fF-0007dP-Gg for qemu-devel@nongnu.org; Mon, 24 Sep 2012 05:09:23 -0400 Received: from e23smtp07.au.ibm.com ([202.81.31.140]:52118) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TG4fE-0007d7-UP for qemu-devel@nongnu.org; Mon, 24 Sep 2012 05:09:17 -0400 Received: from /spool/local by e23smtp07.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 24 Sep 2012 19:06:53 +1000 Received: from d23relay04.au.ibm.com (202.81.31.246) by e23smtp07.au.ibm.com (202.81.31.204) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 24 Sep 2012 19:06:41 +1000 Received: from d23av02.au.ibm.com (d23av02.au.ibm.com [9.190.235.138]) by d23relay04.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q8O8xagr27590828 for ; Mon, 24 Sep 2012 18:59:36 +1000 Received: from d23av02.au.ibm.com (loopback [127.0.0.1]) by d23av02.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q8O98wNo000356 for ; Mon, 24 Sep 2012 19:08:58 +1000 Received: from in.ibm.com ([9.79.202.140]) by d23av02.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q8O98n91032251 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Mon, 24 Sep 2012 19:08:53 +1000 Date: Mon, 24 Sep 2012 14:40:56 +0530 From: Bharata B Rao To: qemu-devel@nongnu.org Message-ID: <20120924091056.GK18470@in.ibm.com> References: <20120924091008.GJ18470@in.ibm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20120924091008.GJ18470@in.ibm.com> User-Agent: Mutt/1.5.21 (2010-09-15) x-cbid: 12092409-0260-0000-0000-000001E3827F X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 202.81.31.140 Cc: Kevin Wolf , Anthony Liguori , Anand Avati , Vijay Bellur , Stefan Hajnoczi , Harsh Bora , Amar Tumballi , "Richard W.M. Jones" , Daniel Veillard , Blue Swirl , Avi Kivity , Paolo Bonzini Subject: [Qemu-devel] [PATCH v9 1/4] 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;