qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Bharata B Rao <bharata@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
	Anthony Liguori <aliguori@us.ibm.com>,
	Anand Avati <aavati@redhat.com>,
	Vijay Bellur <vbellur@redhat.com>,
	Stefan Hajnoczi <stefanha@gmail.com>,
	Harsh Bora <harsh@linux.vnet.ibm.com>,
	Amar Tumballi <amarts@redhat.com>,
	"Richard W.M. Jones" <rjones@redhat.com>,
	Daniel Veillard <veillard@redhat.com>,
	Blue Swirl <blauwirbel@gmail.com>, Avi Kivity <avi@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>
Subject: [Qemu-devel] [PATCH v10 2/5] aio: Another fix to the walking_handlers logic
Date: Thu, 27 Sep 2012 19:27:43 +0530	[thread overview]
Message-ID: <20120927135743.GF18285@in.ibm.com> (raw)
In-Reply-To: <20120927135553.GD18285@in.ibm.com>

aio: Another fix to the walking_handlers logic

From: Paolo Bonzini <pbonzini@redhat.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 <pbonzini@redhat.com>
Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
---

 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;

  parent reply	other threads:[~2012-09-27 13:56 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-27 13:55 [Qemu-devel] [PATCH v10 0/5] GlusterFS support in QEMU - v10 Bharata B Rao
2012-09-27 13:56 ` [Qemu-devel] [PATCH v10 1/5] aio: Fix qemu_aio_wait() to maintain correct walking_handlers count Bharata B Rao
2012-09-27 13:57 ` Bharata B Rao [this message]
2012-09-27 13:58 ` [Qemu-devel] [PATCH v10 3/5] qemu: URI parsing library Bharata B Rao
2012-09-27 14:36   ` Daniel P. Berrange
2012-09-27 15:55     ` Paolo Bonzini
2012-09-28  8:39       ` Daniel P. Berrange
2012-09-28  9:47         ` Paolo Bonzini
2012-09-27 13:59 ` [Qemu-devel] [PATCH v10 4/5] configure: Add a config option for GlusterFS as block backend Bharata B Rao
2012-09-27 14:00 ` [Qemu-devel] [PATCH v10 5/5] block: Support GlusterFS as a QEMU " Bharata B Rao
2012-09-28 18:23 ` [Qemu-devel] [PATCH v10 0/5] GlusterFS support in QEMU - v10 Kevin Wolf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120927135743.GF18285@in.ibm.com \
    --to=bharata@linux.vnet.ibm.com \
    --cc=aavati@redhat.com \
    --cc=aliguori@us.ibm.com \
    --cc=amarts@redhat.com \
    --cc=avi@redhat.com \
    --cc=blauwirbel@gmail.com \
    --cc=harsh@linux.vnet.ibm.com \
    --cc=kwolf@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rjones@redhat.com \
    --cc=stefanha@gmail.com \
    --cc=vbellur@redhat.com \
    --cc=veillard@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).