From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:54437) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TG4PT-0005ps-7B for qemu-devel@nongnu.org; Mon, 24 Sep 2012 04:53:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TG4PN-0001ig-D8 for qemu-devel@nongnu.org; Mon, 24 Sep 2012 04:52:59 -0400 Received: from e28smtp07.in.ibm.com ([122.248.162.7]:38802) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TG4PM-0001i5-Q2 for qemu-devel@nongnu.org; Mon, 24 Sep 2012 04:52:53 -0400 Received: from /spool/local by e28smtp07.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 24 Sep 2012 14:22:47 +0530 Received: from d28av01.in.ibm.com (d28av01.in.ibm.com [9.184.220.63]) by d28relay05.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q8O8qZpI3867042 for ; Mon, 24 Sep 2012 14:22:35 +0530 Received: from d28av01.in.ibm.com (loopback [127.0.0.1]) by d28av01.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q8OEMBCQ030496 for ; Mon, 24 Sep 2012 19:52:12 +0530 Date: Mon, 24 Sep 2012 14:24:37 +0530 From: Bharata B Rao Message-ID: <20120924085437.GG18470@in.ibm.com> References: <20120924085127.GC18470@in.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20120924085127.GC18470@in.ibm.com> Subject: [Qemu-devel] [PATCH v8 4/6] 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 , Markus Armbruster , 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;