xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Ian Jackson <ian.jackson@eu.citrix.com>
To: xen-devel@lists.xensource.com
Cc: Ian Jackson <Ian.Jackson@eu.citrix.com>,
	Ian Campbell <ian.campbell@citrix.com>
Subject: [PATCH 10/14] libxl: ao: Record ultimate parent of a nested ao
Date: Fri, 20 Dec 2013 18:45:48 +0000	[thread overview]
Message-ID: <1387565152-5642-11-git-send-email-ian.jackson@eu.citrix.com> (raw)
In-Reply-To: <1387565152-5642-1-git-send-email-ian.jackson@eu.citrix.com>

This will be used by the cancellation machinery.

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

diff --git a/tools/libxl/libxl_event.c b/tools/libxl/libxl_event.c
index 28b134a..8eb3483 100644
--- a/tools/libxl/libxl_event.c
+++ b/tools/libxl/libxl_event.c
@@ -31,6 +31,9 @@
 #define DBG(args, ...) LIBXL__DBG_LOG(CTX, args, __VA_ARGS__)
 
 
+static libxl__ao *ao_nested_root(libxl__ao *ao);
+
+
 /*
  * The counter osevent_in_hook is used to ensure that the application
  * honours the reentrancy restriction documented in libxl_event.h.
@@ -1700,7 +1703,7 @@ void libxl__ao_complete(libxl__egc *egc, libxl__ao *ao, int rc)
     LOG(DEBUG,"ao %p: complete, rc=%d",ao,rc);
     assert(ao->magic == LIBXL__AO_MAGIC);
     assert(!ao->complete);
-    assert(!ao->nested);
+    assert(!ao->nested_root);
     ao->complete = 1;
     ao->rc = rc;
 
@@ -1865,7 +1868,7 @@ void libxl__ao_progress_report(libxl__egc *egc, libxl__ao *ao,
         const libxl_asyncprogress_how *how, libxl_event *ev)
 {
     AO_GC;
-    assert(!ao->nested);
+    assert(!ao->nested_root);
     if (how->callback == dummy_asyncprogress_callback_ignore) {
         LOG(DEBUG,"ao %p: progress report: ignored",ao);
         libxl_event_free(CTX,ev);
@@ -1888,21 +1891,23 @@ void libxl__ao_progress_report(libxl__egc *egc, libxl__ao *ao,
 
 /* nested ao */
 
+static libxl__ao *ao_nested_root(libxl__ao *ao) {
+    libxl__ao *root = ao->nested_root ? : ao;
+    assert(!root->nested_root);
+    return root;
+}
+
 _hidden libxl__ao *libxl__nested_ao_create(libxl__ao *parent)
 {
-    /* We only use the parent to get the ctx.  However, we require the
-     * caller to provide us with an ao, not just a ctx, to prove that
-     * they are already in an asynchronous operation.  That will avoid
-     * people using this to (for example) make an ao in a non-ao_how
-     * function somewhere in the middle of libxl. */
-    libxl__ao *child = NULL;
+    libxl__ao *child = NULL, *root;
     libxl_ctx *ctx = libxl__gc_owner(&parent->gc);
 
     assert(parent->magic == LIBXL__AO_MAGIC);
+    root = ao_nested_root(parent);
 
     child = libxl__zalloc(&ctx->nogc_gc, sizeof(*child));
     child->magic = LIBXL__AO_MAGIC;
-    child->nested = 1;
+    child->nested_root = root;
     LIBXL_INIT_GC(child->gc, ctx);
     libxl__gc *gc = &child->gc;
 
@@ -1913,7 +1918,7 @@ _hidden libxl__ao *libxl__nested_ao_create(libxl__ao *parent)
 _hidden void libxl__nested_ao_free(libxl__ao *child)
 {
     assert(child->magic == LIBXL__AO_MAGIC);
-    assert(child->nested);
+    assert(child->nested_root);
     libxl_ctx *ctx = libxl__gc_owner(&child->gc);
     libxl__ao__destroy(ctx, child);
 }
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index b2109ea..3213d73 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -443,7 +443,8 @@ struct libxl__ao {
      * only in libxl__ao_complete.)
      */
     uint32_t magic;
-    unsigned constructing:1, in_initiator:1, complete:1, notified:1, nested:1;
+    unsigned constructing:1, in_initiator:1, complete:1, notified:1;
+    libxl__ao *nested_root;
     int progress_reports_outstanding;
     int rc;
     libxl__gc gc;
-- 
1.7.10.4

  parent reply	other threads:[~2013-12-20 18:45 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <4B8F5D33B081C044AA43634E84ED7F9616A83D@AMSPEX01CL03.citrite.net>
2013-10-23 17:23 ` FW: Cancelling asynchronous operations in libxl Konrad Rzeszutek Wilk
2013-10-26  8:33   ` Ian Campbell
     [not found]   ` <1382776392.22417.179.camel@hastur.hellion.org.uk>
2013-10-28  9:38     ` Simon Beaumont
2013-10-28 15:52     ` Ian Jackson
2013-10-31 13:52       ` Ian Campbell
2013-10-31 14:32         ` Ian Jackson
2013-10-31 17:09           ` Ian Campbell
2013-11-08 18:38             ` Ian Jackson
2013-11-20 11:01               ` Ian Campbell
2013-12-20 18:24                 ` Ian Jackson
2013-12-20 18:45                   ` [RFC PATCH 00/14] libxl: Asynchronous event cancellation Ian Jackson
2013-12-20 18:45                     ` [PATCH 01/14] libxl: suspend: switch_logdirty_done takes rc Ian Jackson
2013-12-20 18:45                     ` [PATCH 02/14] libxl: suspend: common suspend callbacks take rc Ian Jackson
2013-12-20 18:45                     ` [PATCH 03/14] libxl: suspend: Return correct error from callbacks Ian Jackson
2013-12-20 18:45                     ` [PATCH 04/14] libxl: Use libxl__xswait* in libxl__ao_device Ian Jackson
2013-12-20 18:45                     ` [PATCH 05/14] libxl: xswait/devstate: Move xswait to before devstate Ian Jackson
2013-12-20 18:45                     ` [PATCH 06/14] libxl: devstate: Use libxl__xswait* Ian Jackson
2013-12-20 18:45                     ` [PATCH 07/14] libxl: New error codes CANCELLED etc Ian Jackson
2013-12-20 18:45                     ` [PATCH 08/14] libxl: events: Permit timeouts to signal cancellation Ian Jackson
2013-12-20 18:45                     ` [PATCH 09/14] libxl: domain create: Do not destroy on cancellation Ian Jackson
2013-12-20 18:45                     ` Ian Jackson [this message]
2013-12-20 18:45                     ` [PATCH 11/14] libxl: ao: Count the nested progeny of an ao Ian Jackson
2013-12-20 18:45                     ` [PATCH 12/14] libxl: ao: Provide manip_refcnt Ian Jackson
2013-12-20 18:45                     ` [PATCH 13/14] libxl: ao: Cancellation API Ian Jackson
2013-12-20 18:45                     ` [PATCH 14/14] libxl: ao: Timeouts are cancellable Ian Jackson
2014-03-14 10:42                   ` FW: Cancelling asynchronous operations in libxl Ian Campbell
2014-03-14 12:32                     ` Simon Beaumont
2014-03-14 17:09                     ` Ian Jackson

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=1387565152-5642-11-git-send-email-ian.jackson@eu.citrix.com \
    --to=ian.jackson@eu.citrix.com \
    --cc=ian.campbell@citrix.com \
    --cc=xen-devel@lists.xensource.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).