From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:46879) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TGAEo-0004ou-Lb for qemu-devel@nongnu.org; Mon, 24 Sep 2012 11:06:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TGAEm-0005yR-IJ for qemu-devel@nongnu.org; Mon, 24 Sep 2012 11:06:22 -0400 Received: from mail-bk0-f45.google.com ([209.85.214.45]:49737) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TGAEm-0005yH-5g for qemu-devel@nongnu.org; Mon, 24 Sep 2012 11:06:20 -0400 Received: by bkcjg9 with SMTP id jg9so2401739bkc.4 for ; Mon, 24 Sep 2012 08:06:19 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Mon, 24 Sep 2012 17:06:11 +0200 Message-Id: <1348499171-15791-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH] aio: another fix to the walking_handlers logic List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, stefanha@gmail.com, bharata@linux.vnet.ibm.com 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 --- This is on top of the existing fix that is posted as part of the glusterfs series. Bharata, can you add this patch as well? aio.c | 10 +++++----- 1 file modificato, 5 inserzioni(+), 5 rimozioni(-) 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; -- 1.7.12