From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:44300) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1THEYN-0003Yx-83 for qemu-devel@nongnu.org; Thu, 27 Sep 2012 09:55:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1THEYM-00050O-1h for qemu-devel@nongnu.org; Thu, 27 Sep 2012 09:54:59 -0400 Received: from e23smtp03.au.ibm.com ([202.81.31.145]:40346) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1THEYL-000502-GU for qemu-devel@nongnu.org; Thu, 27 Sep 2012 09:54:57 -0400 Received: from /spool/local by e23smtp03.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 27 Sep 2012 23:52:58 +1000 Received: from d23av01.au.ibm.com (d23av01.au.ibm.com [9.190.234.96]) by d23relay03.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q8RDsrcM31064266 for ; Thu, 27 Sep 2012 23:54:53 +1000 Received: from d23av01.au.ibm.com (loopback [127.0.0.1]) by d23av01.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q8RDsrIv028436 for ; Thu, 27 Sep 2012 23:54:53 +1000 Date: Thu, 27 Sep 2012 19:26:52 +0530 From: Bharata B Rao Message-ID: <20120927135652.GE18285@in.ibm.com> References: <20120927135553.GD18285@in.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20120927135553.GD18285@in.ibm.com> Subject: [Qemu-devel] [PATCH v10 1/5] aio: Fix qemu_aio_wait() to maintain correct walking_handlers count Reply-To: bharata@linux.vnet.ibm.com List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org 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 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;