From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:44558) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1THEZH-0004bf-Mi for qemu-devel@nongnu.org; Thu, 27 Sep 2012 09:56:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1THEZD-0005wa-I8 for qemu-devel@nongnu.org; Thu, 27 Sep 2012 09:55:55 -0400 Received: from e23smtp03.au.ibm.com ([202.81.31.145]:40383) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1THEZC-0005sG-V3 for qemu-devel@nongnu.org; Thu, 27 Sep 2012 09:55:51 -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:53:51 +1000 Received: from d23av02.au.ibm.com (d23av02.au.ibm.com [9.190.235.138]) by d23relay05.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q8RDkAPN13697126 for ; Thu, 27 Sep 2012 23:46:10 +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 q8RDti6h019544 for ; Thu, 27 Sep 2012 23:55:45 +1000 Date: Thu, 27 Sep 2012 19:27:43 +0530 From: Bharata B Rao Message-ID: <20120927135743.GF18285@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 2/5] aio: Another fix to the walking_handlers logic 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: Another fix to the walking_handlers logic From: Paolo Bonzini The AIO dispatch loop will call QLIST_REMOVE and g_free even if there are other pending calls to qemu_aio_wait outside the current one. Signed-off-by: Paolo Bonzini Signed-off-by: Bharata B Rao --- aio.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-) diff --git a/aio.c b/aio.c index 99b8b72..c738a4e 100644 --- a/aio.c +++ b/aio.c @@ -159,14 +159,14 @@ bool qemu_aio_wait(void) /* if we have any readable fds, dispatch event */ if (ret > 0) { - walking_handlers++; - /* we have to walk very carefully in case * qemu_aio_set_fd_handler is called while we're walking */ node = QLIST_FIRST(&aio_handlers); while (node) { AioHandler *tmp; + walking_handlers++; + if (!node->deleted && FD_ISSET(node->fd, &rdfds) && node->io_read) { @@ -181,13 +181,13 @@ bool qemu_aio_wait(void) tmp = node; node = QLIST_NEXT(node, node); - if (tmp->deleted) { + walking_handlers--; + + if (!walking_handlers && tmp->deleted) { QLIST_REMOVE(tmp, node); g_free(tmp); } } - - walking_handlers--; } return true;