From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Jackson Subject: [PATCH 15/29] libxl: ao: Count the nested progeny of an ao Date: Tue, 10 Feb 2015 20:10:02 +0000 Message-ID: <1423599016-32639-16-git-send-email-ian.jackson@eu.citrix.com> References: <1423599016-32639-1-git-send-email-ian.jackson@eu.citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1423599016-32639-1-git-send-email-ian.jackson@eu.citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xensource.com Cc: Ian Jackson , Euan Harris List-Id: xen-devel@lists.xenproject.org This will detect any "escaped" nested aos. Signed-off-by: Ian Jackson --- tools/libxl/libxl_event.c | 8 +++++++- tools/libxl/libxl_internal.h | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/libxl/libxl_event.c b/tools/libxl/libxl_event.c index 1385a94..37c3d2f 100644 --- a/tools/libxl/libxl_event.c +++ b/tools/libxl/libxl_event.c @@ -1762,6 +1762,7 @@ void libxl__ao_complete(libxl__egc *egc, libxl__ao *ao, int rc) assert(ao->magic == LIBXL__AO_MAGIC); assert(!ao->complete); assert(!ao->nested_root); + assert(!ao->nested_progeny); ao->complete = 1; ao->rc = rc; @@ -1972,6 +1973,8 @@ _hidden libxl__ao *libxl__nested_ao_create(libxl__ao *parent) child = libxl__zalloc(&ctx->nogc_gc, sizeof(*child)); child->magic = LIBXL__AO_MAGIC; child->nested_root = root; + assert(root->nested_progeny < INT_MAX); + root->nested_progeny++; LIBXL_INIT_GC(child->gc, ctx); libxl__gc *gc = &child->gc; @@ -1982,7 +1985,10 @@ _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_root); + libxl__ao *root = child->nested_root; + assert(root); + assert(root->nested_progeny > 0); + root->nested_progeny--; 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 fe5c94f..e29db43 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -450,6 +450,7 @@ struct libxl__ao { uint32_t magic; unsigned constructing:1, in_initiator:1, complete:1, notified:1; libxl__ao *nested_root; + int nested_progeny; int progress_reports_outstanding; int rc; libxl__gc gc; -- 1.7.10.4