xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Ian Jackson <ian.jackson@eu.citrix.com>
To: xen-devel@lists.xen.org
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Subject: [PATCH 4/4] libxl: events: STATE_AO_GC checks ao is still valid
Date: Tue, 15 May 2012 15:09:59 +0100	[thread overview]
Message-ID: <1337090999-15608-5-git-send-email-ian.jackson@eu.citrix.com> (raw)
In-Reply-To: <1337090999-15608-1-git-send-email-ian.jackson@eu.citrix.com>

This will catch earlier the mistake where an ao is completed while it
still has events registered: when the event callback happens for the
long-gone ao, we will crash before attempting to execute any of the
operation-specific code.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
 tools/libxl/libxl_event.c    |    7 +++++++
 tools/libxl/libxl_internal.h |    3 ++-
 2 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/tools/libxl/libxl_event.c b/tools/libxl/libxl_event.c
index 0f9ea41..bdbbdd4 100644
--- a/tools/libxl/libxl_event.c
+++ b/tools/libxl/libxl_event.c
@@ -1399,6 +1399,13 @@ void libxl__ao_abort(libxl__ao *ao)
     libxl__ao__destroy(CTX, ao);
 }
 
+libxl__gc *libxl__ao_inprogress_gc(libxl__ao *ao)
+{
+    assert(ao->magic == LIBXL__AO_MAGIC);
+    assert(!ao->complete);
+    return &ao->gc;
+}
+
 void libxl__ao_complete(libxl__egc *egc, libxl__ao *ao, int rc)
 {
     assert(ao->magic == LIBXL__AO_MAGIC);
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index b2fe8bb..73b9915 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -1575,7 +1575,7 @@ _hidden void libxl__egc_cleanup(libxl__egc *egc);
 
 #define STATE_AO_GC(op_ao)                      \
     libxl__ao *const ao = (op_ao);              \
-    AO_GC
+    libxl__gc *const gc __attribute__((unused)) = libxl__ao_inprogress_gc(ao)
 
 
 /* All of these MUST be called with the ctx locked.
@@ -1585,6 +1585,7 @@ _hidden libxl__ao *libxl__ao_create(libxl_ctx*, uint32_t domid,
 _hidden int libxl__ao_inprogress(libxl__ao *ao); /* temporarily unlocks */
 _hidden void libxl__ao_abort(libxl__ao *ao);
 _hidden void libxl__ao_complete(libxl__egc *egc, libxl__ao *ao, int rc);
+_hidden libxl__gc *libxl__ao_inprogress_gc(libxl__ao *ao);
 
 /* Can be called at any time.  Use is essential for any aop user. */
 _hidden void libxl__ao_progress_gethow(libxl_asyncprogress_how *in_state,
-- 
1.7.2.5

  parent reply	other threads:[~2012-05-15 14:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-15 14:09 libxl: events: debugging improvements Ian Jackson
2012-05-15 14:09 ` [PATCH 1/4] libxl: events: debugging output for timeouts Ian Jackson
2012-05-15 14:09 ` [PATCH 2/4] libxl: events: improve debugging output for xs watches Ian Jackson
2012-05-15 14:09 ` [PATCH 3/4] libxl: events: debugging output for fds Ian Jackson
2012-05-15 14:09 ` Ian Jackson [this message]
2012-05-17 13:46 ` libxl: events: debugging improvements Ian Campbell

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=1337090999-15608-5-git-send-email-ian.jackson@eu.citrix.com \
    --to=ian.jackson@eu.citrix.com \
    --cc=xen-devel@lists.xen.org \
    /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).