From mboxrd@z Thu Jan 1 00:00:00 1970 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 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 Date: Mon, 17 Sep 2012 20:54:45 +0530 From: Bharata B Rao Message-ID: <20120917152445.GE6879@in.ibm.com> References: <20120917152149.GB6879@in.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20120917152149.GB6879@in.ibm.com> Subject: [Qemu-devel] [PATCH v7 3/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 , 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;